@purjayadi/react-native-datepicker 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -13,6 +13,15 @@ A flexible and customizable React Native datepicker component with bottom sheet
13
13
  - 🎯 Min/Max date range support
14
14
  - ♿ Safe area support
15
15
 
16
+ ## Screenshots
17
+
18
+ <div align="center">
19
+ <img src="https://github.com/purjayadi/react-native-datepicker/blob/main/screenshot/1.png" width="250" alt="Screenshot 1" />
20
+ <img src="https://github.com/purjayadi/react-native-datepicker/blob/main/screenshot/2.png" width="250" alt="Screenshot 2" />
21
+ <img src="https://github.com/purjayadi/react-native-datepicker/blob/main/screenshot/3.png" width="250" alt="Screenshot 3" />
22
+ <img src="https://github.com/purjayadi/react-native-datepicker/blob/main/screenshot/4.png" width="250" alt="Screenshot 4" />
23
+ </div>
24
+
16
25
  ## Installation
17
26
 
18
27
  ```bash
@@ -140,31 +149,71 @@ export default function App() {
140
149
  />
141
150
  ```
142
151
 
152
+ ### With Custom Date Format
153
+
154
+ ```tsx
155
+ // ISO format: "2026-02-06"
156
+ <DatePicker
157
+ ref={datePickerRef}
158
+ label="Select Date"
159
+ value={selectedDate}
160
+ onChange={setSelectedDate}
161
+ dateFormat="yyyy-MM-dd"
162
+ />
163
+
164
+ // US format: "02/06/2026"
165
+ <DatePicker
166
+ ref={datePickerRef}
167
+ label="Select Date"
168
+ value={selectedDate}
169
+ onChange={setSelectedDate}
170
+ dateFormat="MM/dd/yyyy"
171
+ />
172
+
173
+ // Custom format with time: "Feb 06, 2026 3:30 PM"
174
+ <DatePicker
175
+ ref={datePickerRef}
176
+ label="Select Date & Time"
177
+ value={selectedDateTime}
178
+ onChange={setSelectedDateTime}
179
+ showTimePicker
180
+ dateFormat="MMM dd, yyyy h:mm a"
181
+ />
182
+ ```
183
+
184
+ > **Note:** Date format uses [date-fns format tokens](https://date-fns.org/v3.3.1/docs/format). Common formats:
185
+ >
186
+ > - `yyyy-MM-dd` → 2026-02-06
187
+ > - `dd/MM/yyyy` → 06/02/2026
188
+ > - `MMM dd, yyyy` → Feb 06, 2026
189
+ > - `MMMM dd, yyyy HH:mm` → February 06, 2026 15:30
190
+
143
191
  ## API Reference
144
192
 
145
193
  ### Props
146
194
 
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 |
195
+ | Prop | Type | Default | Description |
196
+ | ----------------------- | --------------------------- | ----------------------------------------- | ----------------------------------------- |
197
+ | `value` | `string` | `undefined` | Current selected date string |
198
+ | `label` | `string` | `undefined` | Label text above the input |
199
+ | `placeholder` | `string` | `"Select Date"` | Placeholder text when no date is selected |
200
+ | `onChange` | `(date: string) => void` | **required** | Callback when date is selected |
201
+ | `minDate` | `string` | `undefined` | Minimum selectable date (ISO format) |
202
+ | `maxDate` | `string` | `undefined` | Maximum selectable date (ISO format) |
203
+ | `showTimePicker` | `boolean` | `false` | Show time picker in addition to date |
204
+ | `dateFormat` | `string` | `"dd MMMM yyyy"` or `"dd MMM yyyy HH:mm"` | Custom date format (uses date-fns format) |
205
+ | `subText` | `string \| React.ReactNode` | `undefined` | Subtitle text below label |
206
+ | `errors` | `string[]` | `undefined` | Array of error messages |
207
+ | `inputStyle` | `ViewStyle` | `undefined` | Custom style for input container |
208
+ | `inputTextStyle` | `TextStyle` | `undefined` | Custom style for input text |
209
+ | `labelStyle` | `TextStyle` | `undefined` | Custom style for label |
210
+ | `errorStyle` | `TextStyle` | `undefined` | Custom style for error text |
211
+ | `subTextStyle` | `TextStyle` | `undefined` | Custom style for subtitle text |
212
+ | `highlightColor` | `string` | `"#E5E5E5"` | Color of the picker highlight |
213
+ | `buttonStyle` | `ViewStyle` | `undefined` | Custom style for save button |
214
+ | `buttonTextStyle` | `TextStyle` | `undefined` | Custom style for save button text |
215
+ | `cancelButtonStyle` | `ViewStyle` | `undefined` | Custom style for cancel button |
216
+ | `cancelButtonTextStyle` | `TextStyle` | `undefined` | Custom style for cancel button text |
168
217
 
169
218
  ### Ref Methods
170
219
 
package/dist/index.d.mts CHANGED
@@ -12,6 +12,7 @@ interface DatePickerProps {
12
12
  minDate?: string;
13
13
  maxDate?: string;
14
14
  showTimePicker?: boolean;
15
+ dateFormat?: string;
15
16
  subText?: string | React.ReactNode;
16
17
  errors?: string[];
17
18
  inputStyle?: ViewStyle;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ interface DatePickerProps {
12
12
  minDate?: string;
13
13
  maxDate?: string;
14
14
  showTimePicker?: boolean;
15
+ dateFormat?: string;
15
16
  subText?: string | React.ReactNode;
16
17
  errors?: string[];
17
18
  inputStyle?: ViewStyle;
package/dist/index.js CHANGED
@@ -1,494 +1 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.tsx
31
- var index_exports = {};
32
- __export(index_exports, {
33
- DatePicker: () => DatePicker_default
34
- });
35
- module.exports = __toCommonJS(index_exports);
36
-
37
- // src/DatePicker.tsx
38
- var import_react = __toESM(require("react"));
39
- var import_react_native = require("react-native");
40
- var import_date_fns = require("date-fns");
41
- var import_react_native_wheel_scrollview_picker = __toESM(require("react-native-wheel-scrollview-picker"));
42
- var import_bottom_sheet = require("@gorhom/bottom-sheet");
43
- var import_react_native_safe_area_context = require("react-native-safe-area-context");
44
- var InternalButton = ({ onPress, children, outline, style, textStyle }) => {
45
- return /* @__PURE__ */ import_react.default.createElement(
46
- import_react_native.TouchableOpacity,
47
- {
48
- onPress,
49
- style: [styles.button, outline && styles.buttonOutline, style]
50
- },
51
- /* @__PURE__ */ import_react.default.createElement(
52
- import_react_native.Text,
53
- {
54
- style: [
55
- styles.buttonText,
56
- outline && styles.buttonTextOutline,
57
- textStyle
58
- ]
59
- },
60
- children
61
- )
62
- );
63
- };
64
- var DatePicker = (0, import_react.forwardRef)(
65
- ({
66
- value,
67
- label,
68
- placeholder,
69
- onChange,
70
- minDate,
71
- maxDate,
72
- showTimePicker = false,
73
- subText,
74
- errors,
75
- inputStyle,
76
- inputTextStyle,
77
- labelStyle,
78
- errorStyle,
79
- subTextStyle,
80
- highlightColor = "#E5E5E5",
81
- buttonStyle,
82
- buttonTextStyle,
83
- cancelButtonStyle,
84
- cancelButtonTextStyle
85
- }, ref) => {
86
- const nowYear = (/* @__PURE__ */ new Date()).getFullYear();
87
- const bottomSheetRef = (0, import_react.useRef)(null);
88
- const { bottom: paddingBottom } = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
89
- const fullMonths = (0, import_react.useMemo)(
90
- () => [
91
- "January",
92
- "February",
93
- "March",
94
- "April",
95
- "May",
96
- "June",
97
- "July",
98
- "August",
99
- "September",
100
- "October",
101
- "November",
102
- "December"
103
- ],
104
- []
105
- );
106
- const shortMonths = (0, import_react.useMemo)(
107
- () => [
108
- "Jan",
109
- "Feb",
110
- "Mar",
111
- "Apr",
112
- "May",
113
- "Jun",
114
- "Jul",
115
- "Aug",
116
- "Sep",
117
- "Oct",
118
- "Nov",
119
- "Dec"
120
- ],
121
- []
122
- );
123
- const [day, setDay] = (0, import_react.useState)("01");
124
- const [month, setMonth] = (0, import_react.useState)("January");
125
- const [year, setYear] = (0, import_react.useState)(nowYear);
126
- const [days, setDays] = (0, import_react.useState)([]);
127
- const [years, setYears] = (0, import_react.useState)([]);
128
- const [initComplete, setInitComplete] = (0, import_react.useState)(false);
129
- const [hour, setHour] = (0, import_react.useState)("00");
130
- const [minute, setMinute] = (0, import_react.useState)("00");
131
- const [height, setHeight] = (0, import_react.useState)(180);
132
- const displayMonths = showTimePicker ? shortMonths : fullMonths;
133
- const show = (0, import_react.useCallback)(
134
- (initialDate) => {
135
- const selectedDate = initialDate ? (0, import_date_fns.parse)(initialDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : /* @__PURE__ */ new Date();
136
- const selectedDay = (0, import_date_fns.format)(selectedDate, "dd");
137
- const currentMonthIndex = selectedDate.getMonth();
138
- const selectedMonth = fullMonths[currentMonthIndex];
139
- const selectedYear = (0, import_date_fns.getYear)(selectedDate);
140
- const min = minDate ? (0, import_date_fns.parse)(minDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : (0, import_date_fns.subYears)(/* @__PURE__ */ new Date(), 200);
141
- const max = maxDate ? (0, import_date_fns.parse)(maxDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : /* @__PURE__ */ new Date();
142
- const allYears = Array.from(
143
- { length: 200 },
144
- (_, i) => nowYear - i
145
- ).filter((y) => y >= (0, import_date_fns.getYear)(min) && y <= (0, import_date_fns.getYear)(max));
146
- const totalDays = (0, import_date_fns.getDaysInMonth)(
147
- new Date(selectedYear, currentMonthIndex)
148
- );
149
- const daysArray = Array.from(
150
- { length: totalDays },
151
- (_, i) => `${i + 1}`.padStart(2, "0")
152
- );
153
- setDay(selectedDay);
154
- setMonth(selectedMonth);
155
- setYear(selectedYear);
156
- setYears(allYears);
157
- setDays(daysArray);
158
- setHour((0, import_date_fns.format)(selectedDate, "HH"));
159
- setMinute((0, import_date_fns.format)(selectedDate, "mm"));
160
- setInitComplete(true);
161
- setTimeout(() => bottomSheetRef.current?.present(), 10);
162
- },
163
- [minDate, maxDate, fullMonths]
164
- );
165
- (0, import_react.useImperativeHandle)(ref, () => ({ show }), [show]);
166
- const handleSetDate = () => {
167
- const monthIndex = fullMonths.findIndex((m) => m === month);
168
- const finalDateStr = `${year}-${(monthIndex + 1).toString().padStart(2, "0")}-${day}`;
169
- const finalDate = showTimePicker ? (0, import_date_fns.parse)(
170
- `${finalDateStr} ${hour}:${minute}`,
171
- "yyyy-MM-dd HH:mm",
172
- /* @__PURE__ */ new Date()
173
- ) : (0, import_date_fns.parse)(finalDateStr, "yyyy-MM-dd", /* @__PURE__ */ new Date());
174
- const minDateTime = minDate ? (0, import_date_fns.startOfDay)((0, import_date_fns.parse)(minDate, "yyyy-MM-dd", /* @__PURE__ */ new Date())) : null;
175
- const maxDateTime = maxDate ? (0, import_date_fns.startOfDay)((0, import_date_fns.parse)(maxDate, "yyyy-MM-dd", /* @__PURE__ */ new Date())) : null;
176
- if (minDateTime && (0, import_date_fns.isBefore)((0, import_date_fns.startOfDay)(finalDate), minDateTime) || maxDateTime && (0, import_date_fns.isAfter)((0, import_date_fns.startOfDay)(finalDate), maxDateTime)) {
177
- return;
178
- }
179
- const selectedMonthIndex = fullMonths.findIndex((m) => m === month);
180
- const formattedDate = showTimePicker ? `${day} ${shortMonths[selectedMonthIndex]} ${year} ${hour}:${minute}` : `${day} ${fullMonths[selectedMonthIndex]} ${year}`;
181
- onChange(formattedDate);
182
- bottomSheetRef.current?.close();
183
- };
184
- const handleMonthChange = (val) => {
185
- const fullMonth = showTimePicker ? fullMonths.find((m) => m.startsWith(val)) ?? val : val;
186
- const changedMonthIndex = fullMonths.findIndex((m) => m === fullMonth);
187
- const totalDays = (0, import_date_fns.getDaysInMonth)(new Date(year, changedMonthIndex));
188
- const newDays = Array.from(
189
- { length: totalDays },
190
- (_, i) => `${i + 1}`.padStart(2, "0")
191
- );
192
- setMonth(fullMonth);
193
- setDays(newDays);
194
- };
195
- const handleYearChange = (val) => {
196
- const yearMonthIndex = fullMonths.findIndex((m) => m === month);
197
- const totalDays = (0, import_date_fns.getDaysInMonth)(new Date(val, yearMonthIndex));
198
- const newDays = Array.from(
199
- { length: totalDays },
200
- (_, i) => `${i + 1}`.padStart(2, "0")
201
- );
202
- setYear(val);
203
- setDays(newDays);
204
- };
205
- const findSelectedDayByIndex = days.findIndex((val) => val === day);
206
- const findSelectedMonthByIndex = displayMonths.findIndex(
207
- (val) => showTimePicker ? month.startsWith(val) : val === month
208
- );
209
- const findSelectedYearByIndex = years.findIndex((val) => val === year);
210
- const hours = Array.from({ length: 24 }, (_, i) => `${i}`.padStart(2, "0"));
211
- const minutes = Array.from(
212
- { length: 60 },
213
- (_, i) => `${i}`.padStart(2, "0")
214
- );
215
- const dateValue = (0, import_react.useMemo)(() => {
216
- if (value) {
217
- return value;
218
- }
219
- return placeholder || "Select Date";
220
- }, [value, placeholder]);
221
- const handleLayout = (e) => {
222
- setHeight(e?.nativeEvent?.layout?.height || 180);
223
- };
224
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_react_native.View, { style: styles.container }, label && /* @__PURE__ */ import_react.default.createElement(import_react_native.Text, { style: [styles.label, labelStyle] }, label), subText && /* @__PURE__ */ import_react.default.createElement(import_react_native.Text, { style: [styles.subText, subTextStyle] }, subText), /* @__PURE__ */ import_react.default.createElement(
225
- import_react_native.TouchableOpacity,
226
- {
227
- style: [styles.input, errors && styles.inputError, inputStyle],
228
- onPress: () => show(value)
229
- },
230
- /* @__PURE__ */ import_react.default.createElement(
231
- import_react_native.Text,
232
- {
233
- style: [
234
- styles.inputText,
235
- !value && styles.inputTextPlaceholder,
236
- inputTextStyle
237
- ]
238
- },
239
- dateValue
240
- )
241
- ), errors && errors.length > 0 && /* @__PURE__ */ import_react.default.createElement(import_react_native.Text, { style: [styles.errorText, errorStyle] }, errors[0])), /* @__PURE__ */ import_react.default.createElement(
242
- import_bottom_sheet.BottomSheetModal,
243
- {
244
- ref: bottomSheetRef,
245
- snapPoints: ["50%"],
246
- backgroundStyle: { backgroundColor: "#fff" },
247
- enableDynamicSizing: false,
248
- backdropComponent: (props) => /* @__PURE__ */ import_react.default.createElement(
249
- import_bottom_sheet.BottomSheetBackdrop,
250
- {
251
- ...props,
252
- disappearsOnIndex: -1,
253
- appearsOnIndex: 0
254
- }
255
- ),
256
- enableContentPanningGesture: false,
257
- enableHandlePanningGesture: false,
258
- enablePanDownToClose: false
259
- },
260
- initComplete && /* @__PURE__ */ import_react.default.createElement(import_react_native.View, { style: styles.modalContent }, /* @__PURE__ */ import_react.default.createElement(import_react_native.View, null, /* @__PURE__ */ import_react.default.createElement(import_react_native.Text, { style: styles.modalTitle }, "Select Date ", showTimePicker ? "& Time" : "")), /* @__PURE__ */ import_react.default.createElement(import_react_native.View, { style: styles.pickerContainer, onLayout: handleLayout }, /* @__PURE__ */ import_react.default.createElement(
261
- import_react_native_wheel_scrollview_picker.default,
262
- {
263
- dataSource: days,
264
- selectedIndex: findSelectedDayByIndex,
265
- renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
266
- import_react_native.Text,
267
- {
268
- style: data === day ? styles.pickerItemBold : styles.pickerItem
269
- },
270
- data
271
- ),
272
- onValueChange: (value2) => setDay(value2),
273
- wrapperHeight: height,
274
- itemHeight: 40,
275
- highlightBorderWidth: 0.5,
276
- highlightColor,
277
- wrapperBackground: "#FFFFFF"
278
- }
279
- ), /* @__PURE__ */ import_react.default.createElement(
280
- import_react_native_wheel_scrollview_picker.default,
281
- {
282
- dataSource: displayMonths,
283
- selectedIndex: findSelectedMonthByIndex,
284
- renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
285
- import_react_native.Text,
286
- {
287
- style: data === (showTimePicker ? month.slice(0, 3) : month) ? styles.pickerItemBold : styles.pickerItem
288
- },
289
- data
290
- ),
291
- onValueChange: (value2) => handleMonthChange(value2),
292
- wrapperHeight: height,
293
- itemHeight: 40,
294
- highlightBorderWidth: 0.5,
295
- highlightColor,
296
- wrapperBackground: "#FFFFFF"
297
- }
298
- ), /* @__PURE__ */ import_react.default.createElement(
299
- import_react_native_wheel_scrollview_picker.default,
300
- {
301
- dataSource: years,
302
- selectedIndex: findSelectedYearByIndex,
303
- renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
304
- import_react_native.Text,
305
- {
306
- style: data === year ? styles.pickerItemBold : styles.pickerItem
307
- },
308
- data
309
- ),
310
- onValueChange: (value2) => handleYearChange(value2),
311
- wrapperHeight: height,
312
- itemHeight: 40,
313
- highlightBorderWidth: 0.5,
314
- highlightColor,
315
- wrapperBackground: "#FFFFFF"
316
- }
317
- ), showTimePicker && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
318
- import_react_native_wheel_scrollview_picker.default,
319
- {
320
- dataSource: hours,
321
- selectedIndex: hours.findIndex((val) => val === hour),
322
- renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
323
- import_react_native.Text,
324
- {
325
- style: data === hour ? styles.pickerItemBold : styles.pickerItem
326
- },
327
- data
328
- ),
329
- onValueChange: (value2) => setHour(value2),
330
- wrapperHeight: height,
331
- itemHeight: 40,
332
- highlightBorderWidth: 0.5,
333
- highlightColor,
334
- wrapperBackground: "#FFFFFF"
335
- }
336
- ), /* @__PURE__ */ import_react.default.createElement(
337
- import_react_native_wheel_scrollview_picker.default,
338
- {
339
- dataSource: minutes,
340
- selectedIndex: minutes.findIndex((val) => val === minute),
341
- renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
342
- import_react_native.Text,
343
- {
344
- style: data === minute ? styles.pickerItemBold : styles.pickerItem
345
- },
346
- data
347
- ),
348
- onValueChange: (value2) => setMinute(value2),
349
- wrapperHeight: height,
350
- itemHeight: 40,
351
- highlightBorderWidth: 0.5,
352
- highlightColor,
353
- wrapperBackground: "#FFFFFF"
354
- }
355
- ))), /* @__PURE__ */ import_react.default.createElement(
356
- import_react_native.View,
357
- {
358
- style: [
359
- styles.buttonContainer,
360
- {
361
- paddingBottom: import_react_native.Platform.OS === "ios" ? paddingBottom : 20
362
- }
363
- ]
364
- },
365
- /* @__PURE__ */ import_react.default.createElement(
366
- InternalButton,
367
- {
368
- onPress: () => bottomSheetRef.current?.close(),
369
- outline: true,
370
- style: cancelButtonStyle,
371
- textStyle: cancelButtonTextStyle
372
- },
373
- "Cancel"
374
- ),
375
- /* @__PURE__ */ import_react.default.createElement(
376
- InternalButton,
377
- {
378
- onPress: handleSetDate,
379
- style: buttonStyle,
380
- textStyle: buttonTextStyle
381
- },
382
- "Save"
383
- )
384
- ))
385
- ));
386
- }
387
- );
388
- var styles = import_react_native.StyleSheet.create({
389
- container: {
390
- flexDirection: "column",
391
- gap: 8
392
- },
393
- label: {
394
- fontSize: 14,
395
- color: "#6B7280"
396
- },
397
- subText: {
398
- fontSize: 14,
399
- color: "#6B7280",
400
- width: "95%"
401
- },
402
- input: {
403
- fontSize: 16,
404
- color: "#000",
405
- backgroundColor: "#F3F4F6",
406
- borderRadius: 16,
407
- padding: 14,
408
- shadowColor: "#000",
409
- shadowOffset: {
410
- width: 0,
411
- height: 2
412
- },
413
- shadowOpacity: 0.1,
414
- shadowRadius: 3,
415
- elevation: 2
416
- },
417
- inputError: {
418
- borderWidth: 1,
419
- borderColor: "#EF4444"
420
- },
421
- inputText: {
422
- fontSize: 16,
423
- color: "#1F2937"
424
- },
425
- inputTextPlaceholder: {
426
- color: "#9CA3AF"
427
- },
428
- errorText: {
429
- fontSize: 12,
430
- color: "#EF4444",
431
- fontWeight: "bold"
432
- },
433
- modalContent: {
434
- flexDirection: "column",
435
- gap: 12,
436
- marginHorizontal: 24,
437
- flex: 1
438
- },
439
- modalTitle: {
440
- fontSize: 20,
441
- fontWeight: "bold",
442
- color: "#1F2937"
443
- },
444
- pickerContainer: {
445
- flexDirection: "row",
446
- justifyContent: "space-between",
447
- paddingVertical: 16,
448
- flex: 1
449
- },
450
- pickerItem: {
451
- fontSize: 16,
452
- color: "#1F2937"
453
- },
454
- pickerItemBold: {
455
- fontSize: 16,
456
- color: "#1F2937",
457
- fontWeight: "bold"
458
- },
459
- buttonContainer: {
460
- flexDirection: "row",
461
- justifyContent: "space-between",
462
- gap: 24,
463
- paddingVertical: 16,
464
- backgroundColor: "#fff"
465
- },
466
- button: {
467
- flex: 1,
468
- backgroundColor: "#3B82F6",
469
- borderRadius: 12,
470
- paddingVertical: 14,
471
- paddingHorizontal: 20,
472
- alignItems: "center",
473
- justifyContent: "center"
474
- },
475
- buttonOutline: {
476
- backgroundColor: "transparent",
477
- borderWidth: 1,
478
- borderColor: "#3B82F6"
479
- },
480
- buttonText: {
481
- color: "#fff",
482
- fontSize: 16,
483
- fontWeight: "600"
484
- },
485
- buttonTextOutline: {
486
- color: "#3B82F6"
487
- }
488
- });
489
- var DatePicker_default = DatePicker;
490
- // Annotate the CommonJS export names for ESM import in node:
491
- 0 && (module.exports = {
492
- DatePicker
493
- });
494
- //# sourceMappingURL=index.js.map
1
+ 'use strict';var t=require('react'),reactNative=require('react-native'),dateFns=require('date-fns'),F=require('react-native-wheel-scrollview-picker'),bottomSheet=require('@gorhom/bottom-sheet');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var t__default=/*#__PURE__*/_interopDefault(t);var F__default=/*#__PURE__*/_interopDefault(F);var m=["January","February","March","April","May","June","July","August","September","October","November","December"],Ne=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=Array.from({length:24},(r,i)=>`${i}`.padStart(2,"0")),R=Array.from({length:60},(r,i)=>`${i}`.padStart(2,"0")),N=r=>Array.from({length:r},(i,g)=>`${g+1}`.padStart(2,"0")),ee=({onPress:r,children:i,outline:g,style:B,textStyle:h})=>t__default.default.createElement(reactNative.TouchableOpacity,{onPress:r,style:[n.button,g&&n.buttonOutline,B]},t__default.default.createElement(reactNative.Text,{style:[n.buttonText,g&&n.buttonTextOutline,h]},i)),Je=t.forwardRef(({value:r,label:i,placeholder:g,onChange:B,minDate:h,maxDate:x,showTimePicker:l=false,dateFormat:k,subText:J,errors:I,inputStyle:ne,inputTextStyle:oe,labelStyle:re,errorStyle:ae,subTextStyle:le,highlightColor:S="#E5E5E5",buttonStyle:ie,buttonTextStyle:se,cancelButtonStyle:de,cancelButtonTextStyle:ce},ye)=>{let L=new Date().getFullYear(),w=t.useRef(null),H=t.useMemo(()=>k||(l?"dd MMM yyyy HH:mm":"dd MMMM yyyy"),[k,l]),[V,_]=t.useState("01"),[f,v]=t.useState("January"),[T,j]=t.useState(L),[U,O]=t.useState([]),[G,ue]=t.useState([]),[ge,he]=t.useState(false),[P,q]=t.useState("00"),[A,K]=t.useState("00"),[b,pe]=t.useState(180),Q=l?Ne:m,W=t.useCallback(e=>{let o;if(e)try{o=dateFns.parse(e,H,new Date),(!o||isNaN(o.getTime()))&&(o=new Date);}catch{o=new Date;}else o=new Date;let s=dateFns.format(o,"dd"),d=o.getMonth(),y=m[d],u=dateFns.getYear(o),z=h?dateFns.parse(h,"yyyy-MM-dd",new Date):dateFns.subYears(new Date,200),we=x?dateFns.parse(x,"yyyy-MM-dd",new Date):new Date,Te=Array.from({length:200},(E,Be)=>L-Be).filter(E=>E>=dateFns.getYear(z)&&E<=dateFns.getYear(we)),Me=dateFns.getDaysInMonth(new Date(u,d)),Ce=N(Me);_(s),v(y),j(u),ue(Te),O(Ce),q(dateFns.format(o,"HH")),K(dateFns.format(o,"mm")),he(true),setTimeout(()=>w.current?.present(),10);},[h,x,l,H]);t.useImperativeHandle(ye,()=>({show:W}),[W]);let fe=()=>{let e=m.findIndex(z=>z===f),o=`${T}-${(e+1).toString().padStart(2,"0")}-${V}`,s=l?dateFns.parse(`${o} ${P}:${A}`,"yyyy-MM-dd HH:mm",new Date):dateFns.parse(o,"yyyy-MM-dd",new Date),d=h?dateFns.startOfDay(dateFns.parse(h,"yyyy-MM-dd",new Date)):null,y=x?dateFns.startOfDay(dateFns.parse(x,"yyyy-MM-dd",new Date)):null;if(d&&dateFns.isBefore(dateFns.startOfDay(s),d)||y&&dateFns.isAfter(dateFns.startOfDay(s),y))return;let u=dateFns.format(s,H);B(u),w.current?.close();},me=e=>{let o=l?m.find(u=>u.startsWith(e))??e:e,s=m.findIndex(u=>u===o),d=dateFns.getDaysInMonth(new Date(T,s)),y=N(d);v(o),O(y);},xe=e=>{let o=m.findIndex(y=>y===f),s=dateFns.getDaysInMonth(new Date(e,o)),d=N(s);j(e),O(d);},Se=U.findIndex(e=>e===V),be=Q.findIndex(e=>l?f.startsWith(e):e===f),De=G.findIndex(e=>e===T),Fe=t.useMemo(()=>r||g||"Select Date",[r,g]),Ie=e=>{pe(e?.nativeEvent?.layout?.height||180);};return t__default.default.createElement(t__default.default.Fragment,null,t__default.default.createElement(reactNative.View,{style:n.container},i&&t__default.default.createElement(reactNative.Text,{style:[n.label,re]},i),J&&t__default.default.createElement(reactNative.Text,{style:[n.subText,le]},J),t__default.default.createElement(reactNative.TouchableOpacity,{style:[n.input,I&&n.inputError,ne],onPress:()=>W(r)},t__default.default.createElement(reactNative.Text,{style:[n.inputText,!r&&n.inputTextPlaceholder,oe]},Fe)),I&&I.length>0&&t__default.default.createElement(reactNative.Text,{style:[n.errorText,ae]},I[0])),t__default.default.createElement(bottomSheet.BottomSheetModal,{ref:w,snapPoints:["50%"],backgroundStyle:{backgroundColor:"#fff"},enableDynamicSizing:false,backdropComponent:e=>t__default.default.createElement(bottomSheet.BottomSheetBackdrop,{...e,disappearsOnIndex:-1,appearsOnIndex:0}),enableContentPanningGesture:false,enableHandlePanningGesture:false,enablePanDownToClose:false},ge&&t__default.default.createElement(reactNative.View,{style:n.modalContent},t__default.default.createElement(reactNative.View,null,t__default.default.createElement(reactNative.Text,{style:n.modalTitle},"Select Date ",l?"& Time":"")),t__default.default.createElement(reactNative.View,{style:n.pickerContainer,onLayout:Ie},t__default.default.createElement(F__default.default,{dataSource:U,selectedIndex:Se,renderItem:e=>t__default.default.createElement(reactNative.Text,{style:e===V?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>_(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}),t__default.default.createElement(F__default.default,{dataSource:Q,selectedIndex:be,renderItem:e=>t__default.default.createElement(reactNative.Text,{style:e===(l?f.slice(0,3):f)?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>me(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}),t__default.default.createElement(F__default.default,{dataSource:G,selectedIndex:De,renderItem:e=>t__default.default.createElement(reactNative.Text,{style:e===T?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>xe(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}),l&&t__default.default.createElement(t__default.default.Fragment,null,t__default.default.createElement(F__default.default,{dataSource:Z,selectedIndex:Z.findIndex(e=>e===P),renderItem:e=>t__default.default.createElement(reactNative.Text,{style:e===P?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>q(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}),t__default.default.createElement(F__default.default,{dataSource:R,selectedIndex:R.findIndex(e=>e===A),renderItem:e=>t__default.default.createElement(reactNative.Text,{style:e===A?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>K(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}))),t__default.default.createElement(reactNative.View,{style:[n.buttonContainer,{paddingBottom:(reactNative.Platform.OS==="ios",20)}]},t__default.default.createElement(ee,{onPress:()=>w.current?.close(),outline:true,style:de,textStyle:ce},"Cancel"),t__default.default.createElement(ee,{onPress:fe,style:ie,textStyle:se},"Save")))))}),n=reactNative.StyleSheet.create({container:{flexDirection:"column",gap:8},label:{fontSize:14,color:"#6B7280"},subText:{fontSize:14,color:"#6B7280",width:"95%"},input:{fontSize:16,color:"#000",backgroundColor:"#F3F4F6",borderRadius:16,padding:14,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.1,shadowRadius:3,elevation:2},inputError:{borderWidth:1,borderColor:"#EF4444"},inputText:{fontSize:16,color:"#1F2937"},inputTextPlaceholder:{color:"#9CA3AF"},errorText:{fontSize:12,color:"#EF4444",fontWeight:"bold"},modalContent:{flexDirection:"column",gap:12,marginHorizontal:24,flex:1},modalTitle:{fontSize:20,fontWeight:"bold",color:"#1F2937"},pickerContainer:{flexDirection:"row",justifyContent:"space-between",paddingVertical:16,flex:1},pickerItem:{fontSize:16,color:"#1F2937"},pickerItemBold:{fontSize:16,color:"#1F2937",fontWeight:"bold"},buttonContainer:{flexDirection:"row",justifyContent:"space-between",gap:24,paddingVertical:16,backgroundColor:"#fff"},button:{flex:1,backgroundColor:"#3B82F6",borderRadius:12,paddingVertical:14,paddingHorizontal:20,alignItems:"center",justifyContent:"center"},buttonOutline:{backgroundColor:"transparent",borderWidth:1,borderColor:"#3B82F6"},buttonText:{color:"#fff",fontSize:16,fontWeight:"600"},buttonTextOutline:{color:"#3B82F6"}}),Le=Je;exports.DatePicker=Le;
package/dist/index.mjs CHANGED
@@ -1,479 +1 @@
1
- // src/DatePicker.tsx
2
- import React, {
3
- useState,
4
- useImperativeHandle,
5
- forwardRef,
6
- useCallback,
7
- useRef,
8
- useMemo
9
- } from "react";
10
- import {
11
- View,
12
- TouchableOpacity,
13
- Platform,
14
- Text,
15
- StyleSheet
16
- } from "react-native";
17
- import {
18
- format,
19
- parse,
20
- getDaysInMonth,
21
- subYears,
22
- isBefore,
23
- isAfter,
24
- getYear,
25
- startOfDay
26
- } from "date-fns";
27
- import ScrollPicker from "react-native-wheel-scrollview-picker";
28
- import { BottomSheetModal, BottomSheetBackdrop } from "@gorhom/bottom-sheet";
29
- import { useSafeAreaInsets } from "react-native-safe-area-context";
30
- var InternalButton = ({ onPress, children, outline, style, textStyle }) => {
31
- return /* @__PURE__ */ React.createElement(
32
- TouchableOpacity,
33
- {
34
- onPress,
35
- style: [styles.button, outline && styles.buttonOutline, style]
36
- },
37
- /* @__PURE__ */ React.createElement(
38
- Text,
39
- {
40
- style: [
41
- styles.buttonText,
42
- outline && styles.buttonTextOutline,
43
- textStyle
44
- ]
45
- },
46
- children
47
- )
48
- );
49
- };
50
- var DatePicker = forwardRef(
51
- ({
52
- value,
53
- label,
54
- placeholder,
55
- onChange,
56
- minDate,
57
- maxDate,
58
- showTimePicker = false,
59
- subText,
60
- errors,
61
- inputStyle,
62
- inputTextStyle,
63
- labelStyle,
64
- errorStyle,
65
- subTextStyle,
66
- highlightColor = "#E5E5E5",
67
- buttonStyle,
68
- buttonTextStyle,
69
- cancelButtonStyle,
70
- cancelButtonTextStyle
71
- }, ref) => {
72
- const nowYear = (/* @__PURE__ */ new Date()).getFullYear();
73
- const bottomSheetRef = useRef(null);
74
- const { bottom: paddingBottom } = useSafeAreaInsets();
75
- const fullMonths = useMemo(
76
- () => [
77
- "January",
78
- "February",
79
- "March",
80
- "April",
81
- "May",
82
- "June",
83
- "July",
84
- "August",
85
- "September",
86
- "October",
87
- "November",
88
- "December"
89
- ],
90
- []
91
- );
92
- const shortMonths = useMemo(
93
- () => [
94
- "Jan",
95
- "Feb",
96
- "Mar",
97
- "Apr",
98
- "May",
99
- "Jun",
100
- "Jul",
101
- "Aug",
102
- "Sep",
103
- "Oct",
104
- "Nov",
105
- "Dec"
106
- ],
107
- []
108
- );
109
- const [day, setDay] = useState("01");
110
- const [month, setMonth] = useState("January");
111
- const [year, setYear] = useState(nowYear);
112
- const [days, setDays] = useState([]);
113
- const [years, setYears] = useState([]);
114
- const [initComplete, setInitComplete] = useState(false);
115
- const [hour, setHour] = useState("00");
116
- const [minute, setMinute] = useState("00");
117
- const [height, setHeight] = useState(180);
118
- const displayMonths = showTimePicker ? shortMonths : fullMonths;
119
- const show = useCallback(
120
- (initialDate) => {
121
- const selectedDate = initialDate ? parse(initialDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : /* @__PURE__ */ new Date();
122
- const selectedDay = format(selectedDate, "dd");
123
- const currentMonthIndex = selectedDate.getMonth();
124
- const selectedMonth = fullMonths[currentMonthIndex];
125
- const selectedYear = getYear(selectedDate);
126
- const min = minDate ? parse(minDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : subYears(/* @__PURE__ */ new Date(), 200);
127
- const max = maxDate ? parse(maxDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : /* @__PURE__ */ new Date();
128
- const allYears = Array.from(
129
- { length: 200 },
130
- (_, i) => nowYear - i
131
- ).filter((y) => y >= getYear(min) && y <= getYear(max));
132
- const totalDays = getDaysInMonth(
133
- new Date(selectedYear, currentMonthIndex)
134
- );
135
- const daysArray = Array.from(
136
- { length: totalDays },
137
- (_, i) => `${i + 1}`.padStart(2, "0")
138
- );
139
- setDay(selectedDay);
140
- setMonth(selectedMonth);
141
- setYear(selectedYear);
142
- setYears(allYears);
143
- setDays(daysArray);
144
- setHour(format(selectedDate, "HH"));
145
- setMinute(format(selectedDate, "mm"));
146
- setInitComplete(true);
147
- setTimeout(() => bottomSheetRef.current?.present(), 10);
148
- },
149
- [minDate, maxDate, fullMonths]
150
- );
151
- useImperativeHandle(ref, () => ({ show }), [show]);
152
- const handleSetDate = () => {
153
- const monthIndex = fullMonths.findIndex((m) => m === month);
154
- const finalDateStr = `${year}-${(monthIndex + 1).toString().padStart(2, "0")}-${day}`;
155
- const finalDate = showTimePicker ? parse(
156
- `${finalDateStr} ${hour}:${minute}`,
157
- "yyyy-MM-dd HH:mm",
158
- /* @__PURE__ */ new Date()
159
- ) : parse(finalDateStr, "yyyy-MM-dd", /* @__PURE__ */ new Date());
160
- const minDateTime = minDate ? startOfDay(parse(minDate, "yyyy-MM-dd", /* @__PURE__ */ new Date())) : null;
161
- const maxDateTime = maxDate ? startOfDay(parse(maxDate, "yyyy-MM-dd", /* @__PURE__ */ new Date())) : null;
162
- if (minDateTime && isBefore(startOfDay(finalDate), minDateTime) || maxDateTime && isAfter(startOfDay(finalDate), maxDateTime)) {
163
- return;
164
- }
165
- const selectedMonthIndex = fullMonths.findIndex((m) => m === month);
166
- const formattedDate = showTimePicker ? `${day} ${shortMonths[selectedMonthIndex]} ${year} ${hour}:${minute}` : `${day} ${fullMonths[selectedMonthIndex]} ${year}`;
167
- onChange(formattedDate);
168
- bottomSheetRef.current?.close();
169
- };
170
- const handleMonthChange = (val) => {
171
- const fullMonth = showTimePicker ? fullMonths.find((m) => m.startsWith(val)) ?? val : val;
172
- const changedMonthIndex = fullMonths.findIndex((m) => m === fullMonth);
173
- const totalDays = getDaysInMonth(new Date(year, changedMonthIndex));
174
- const newDays = Array.from(
175
- { length: totalDays },
176
- (_, i) => `${i + 1}`.padStart(2, "0")
177
- );
178
- setMonth(fullMonth);
179
- setDays(newDays);
180
- };
181
- const handleYearChange = (val) => {
182
- const yearMonthIndex = fullMonths.findIndex((m) => m === month);
183
- const totalDays = getDaysInMonth(new Date(val, yearMonthIndex));
184
- const newDays = Array.from(
185
- { length: totalDays },
186
- (_, i) => `${i + 1}`.padStart(2, "0")
187
- );
188
- setYear(val);
189
- setDays(newDays);
190
- };
191
- const findSelectedDayByIndex = days.findIndex((val) => val === day);
192
- const findSelectedMonthByIndex = displayMonths.findIndex(
193
- (val) => showTimePicker ? month.startsWith(val) : val === month
194
- );
195
- const findSelectedYearByIndex = years.findIndex((val) => val === year);
196
- const hours = Array.from({ length: 24 }, (_, i) => `${i}`.padStart(2, "0"));
197
- const minutes = Array.from(
198
- { length: 60 },
199
- (_, i) => `${i}`.padStart(2, "0")
200
- );
201
- const dateValue = useMemo(() => {
202
- if (value) {
203
- return value;
204
- }
205
- return placeholder || "Select Date";
206
- }, [value, placeholder]);
207
- const handleLayout = (e) => {
208
- setHeight(e?.nativeEvent?.layout?.height || 180);
209
- };
210
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View, { style: styles.container }, label && /* @__PURE__ */ React.createElement(Text, { style: [styles.label, labelStyle] }, label), subText && /* @__PURE__ */ React.createElement(Text, { style: [styles.subText, subTextStyle] }, subText), /* @__PURE__ */ React.createElement(
211
- TouchableOpacity,
212
- {
213
- style: [styles.input, errors && styles.inputError, inputStyle],
214
- onPress: () => show(value)
215
- },
216
- /* @__PURE__ */ React.createElement(
217
- Text,
218
- {
219
- style: [
220
- styles.inputText,
221
- !value && styles.inputTextPlaceholder,
222
- inputTextStyle
223
- ]
224
- },
225
- dateValue
226
- )
227
- ), errors && errors.length > 0 && /* @__PURE__ */ React.createElement(Text, { style: [styles.errorText, errorStyle] }, errors[0])), /* @__PURE__ */ React.createElement(
228
- BottomSheetModal,
229
- {
230
- ref: bottomSheetRef,
231
- snapPoints: ["50%"],
232
- backgroundStyle: { backgroundColor: "#fff" },
233
- enableDynamicSizing: false,
234
- backdropComponent: (props) => /* @__PURE__ */ React.createElement(
235
- BottomSheetBackdrop,
236
- {
237
- ...props,
238
- disappearsOnIndex: -1,
239
- appearsOnIndex: 0
240
- }
241
- ),
242
- enableContentPanningGesture: false,
243
- enableHandlePanningGesture: false,
244
- enablePanDownToClose: false
245
- },
246
- initComplete && /* @__PURE__ */ React.createElement(View, { style: styles.modalContent }, /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(Text, { style: styles.modalTitle }, "Select Date ", showTimePicker ? "& Time" : "")), /* @__PURE__ */ React.createElement(View, { style: styles.pickerContainer, onLayout: handleLayout }, /* @__PURE__ */ React.createElement(
247
- ScrollPicker,
248
- {
249
- dataSource: days,
250
- selectedIndex: findSelectedDayByIndex,
251
- renderItem: (data) => /* @__PURE__ */ React.createElement(
252
- Text,
253
- {
254
- style: data === day ? styles.pickerItemBold : styles.pickerItem
255
- },
256
- data
257
- ),
258
- onValueChange: (value2) => setDay(value2),
259
- wrapperHeight: height,
260
- itemHeight: 40,
261
- highlightBorderWidth: 0.5,
262
- highlightColor,
263
- wrapperBackground: "#FFFFFF"
264
- }
265
- ), /* @__PURE__ */ React.createElement(
266
- ScrollPicker,
267
- {
268
- dataSource: displayMonths,
269
- selectedIndex: findSelectedMonthByIndex,
270
- renderItem: (data) => /* @__PURE__ */ React.createElement(
271
- Text,
272
- {
273
- style: data === (showTimePicker ? month.slice(0, 3) : month) ? styles.pickerItemBold : styles.pickerItem
274
- },
275
- data
276
- ),
277
- onValueChange: (value2) => handleMonthChange(value2),
278
- wrapperHeight: height,
279
- itemHeight: 40,
280
- highlightBorderWidth: 0.5,
281
- highlightColor,
282
- wrapperBackground: "#FFFFFF"
283
- }
284
- ), /* @__PURE__ */ React.createElement(
285
- ScrollPicker,
286
- {
287
- dataSource: years,
288
- selectedIndex: findSelectedYearByIndex,
289
- renderItem: (data) => /* @__PURE__ */ React.createElement(
290
- Text,
291
- {
292
- style: data === year ? styles.pickerItemBold : styles.pickerItem
293
- },
294
- data
295
- ),
296
- onValueChange: (value2) => handleYearChange(value2),
297
- wrapperHeight: height,
298
- itemHeight: 40,
299
- highlightBorderWidth: 0.5,
300
- highlightColor,
301
- wrapperBackground: "#FFFFFF"
302
- }
303
- ), showTimePicker && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
304
- ScrollPicker,
305
- {
306
- dataSource: hours,
307
- selectedIndex: hours.findIndex((val) => val === hour),
308
- renderItem: (data) => /* @__PURE__ */ React.createElement(
309
- Text,
310
- {
311
- style: data === hour ? styles.pickerItemBold : styles.pickerItem
312
- },
313
- data
314
- ),
315
- onValueChange: (value2) => setHour(value2),
316
- wrapperHeight: height,
317
- itemHeight: 40,
318
- highlightBorderWidth: 0.5,
319
- highlightColor,
320
- wrapperBackground: "#FFFFFF"
321
- }
322
- ), /* @__PURE__ */ React.createElement(
323
- ScrollPicker,
324
- {
325
- dataSource: minutes,
326
- selectedIndex: minutes.findIndex((val) => val === minute),
327
- renderItem: (data) => /* @__PURE__ */ React.createElement(
328
- Text,
329
- {
330
- style: data === minute ? styles.pickerItemBold : styles.pickerItem
331
- },
332
- data
333
- ),
334
- onValueChange: (value2) => setMinute(value2),
335
- wrapperHeight: height,
336
- itemHeight: 40,
337
- highlightBorderWidth: 0.5,
338
- highlightColor,
339
- wrapperBackground: "#FFFFFF"
340
- }
341
- ))), /* @__PURE__ */ React.createElement(
342
- View,
343
- {
344
- style: [
345
- styles.buttonContainer,
346
- {
347
- paddingBottom: Platform.OS === "ios" ? paddingBottom : 20
348
- }
349
- ]
350
- },
351
- /* @__PURE__ */ React.createElement(
352
- InternalButton,
353
- {
354
- onPress: () => bottomSheetRef.current?.close(),
355
- outline: true,
356
- style: cancelButtonStyle,
357
- textStyle: cancelButtonTextStyle
358
- },
359
- "Cancel"
360
- ),
361
- /* @__PURE__ */ React.createElement(
362
- InternalButton,
363
- {
364
- onPress: handleSetDate,
365
- style: buttonStyle,
366
- textStyle: buttonTextStyle
367
- },
368
- "Save"
369
- )
370
- ))
371
- ));
372
- }
373
- );
374
- var styles = StyleSheet.create({
375
- container: {
376
- flexDirection: "column",
377
- gap: 8
378
- },
379
- label: {
380
- fontSize: 14,
381
- color: "#6B7280"
382
- },
383
- subText: {
384
- fontSize: 14,
385
- color: "#6B7280",
386
- width: "95%"
387
- },
388
- input: {
389
- fontSize: 16,
390
- color: "#000",
391
- backgroundColor: "#F3F4F6",
392
- borderRadius: 16,
393
- padding: 14,
394
- shadowColor: "#000",
395
- shadowOffset: {
396
- width: 0,
397
- height: 2
398
- },
399
- shadowOpacity: 0.1,
400
- shadowRadius: 3,
401
- elevation: 2
402
- },
403
- inputError: {
404
- borderWidth: 1,
405
- borderColor: "#EF4444"
406
- },
407
- inputText: {
408
- fontSize: 16,
409
- color: "#1F2937"
410
- },
411
- inputTextPlaceholder: {
412
- color: "#9CA3AF"
413
- },
414
- errorText: {
415
- fontSize: 12,
416
- color: "#EF4444",
417
- fontWeight: "bold"
418
- },
419
- modalContent: {
420
- flexDirection: "column",
421
- gap: 12,
422
- marginHorizontal: 24,
423
- flex: 1
424
- },
425
- modalTitle: {
426
- fontSize: 20,
427
- fontWeight: "bold",
428
- color: "#1F2937"
429
- },
430
- pickerContainer: {
431
- flexDirection: "row",
432
- justifyContent: "space-between",
433
- paddingVertical: 16,
434
- flex: 1
435
- },
436
- pickerItem: {
437
- fontSize: 16,
438
- color: "#1F2937"
439
- },
440
- pickerItemBold: {
441
- fontSize: 16,
442
- color: "#1F2937",
443
- fontWeight: "bold"
444
- },
445
- buttonContainer: {
446
- flexDirection: "row",
447
- justifyContent: "space-between",
448
- gap: 24,
449
- paddingVertical: 16,
450
- backgroundColor: "#fff"
451
- },
452
- button: {
453
- flex: 1,
454
- backgroundColor: "#3B82F6",
455
- borderRadius: 12,
456
- paddingVertical: 14,
457
- paddingHorizontal: 20,
458
- alignItems: "center",
459
- justifyContent: "center"
460
- },
461
- buttonOutline: {
462
- backgroundColor: "transparent",
463
- borderWidth: 1,
464
- borderColor: "#3B82F6"
465
- },
466
- buttonText: {
467
- color: "#fff",
468
- fontSize: 16,
469
- fontWeight: "600"
470
- },
471
- buttonTextOutline: {
472
- color: "#3B82F6"
473
- }
474
- });
475
- var DatePicker_default = DatePicker;
476
- export {
477
- DatePicker_default as DatePicker
478
- };
479
- //# sourceMappingURL=index.mjs.map
1
+ import t,{forwardRef,useRef,useMemo,useState,useCallback,useImperativeHandle}from'react';import {View,Text,TouchableOpacity,Platform,StyleSheet}from'react-native';import {parse,format,getYear,subYears,getDaysInMonth,startOfDay,isBefore,isAfter}from'date-fns';import F from'react-native-wheel-scrollview-picker';import {BottomSheetModal,BottomSheetBackdrop}from'@gorhom/bottom-sheet';var m=["January","February","March","April","May","June","July","August","September","October","November","December"],Ne=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z=Array.from({length:24},(r,i)=>`${i}`.padStart(2,"0")),R=Array.from({length:60},(r,i)=>`${i}`.padStart(2,"0")),N=r=>Array.from({length:r},(i,g)=>`${g+1}`.padStart(2,"0")),ee=({onPress:r,children:i,outline:g,style:B,textStyle:h})=>t.createElement(TouchableOpacity,{onPress:r,style:[n.button,g&&n.buttonOutline,B]},t.createElement(Text,{style:[n.buttonText,g&&n.buttonTextOutline,h]},i)),Je=forwardRef(({value:r,label:i,placeholder:g,onChange:B,minDate:h,maxDate:x,showTimePicker:l=false,dateFormat:k,subText:J,errors:I,inputStyle:ne,inputTextStyle:oe,labelStyle:re,errorStyle:ae,subTextStyle:le,highlightColor:S="#E5E5E5",buttonStyle:ie,buttonTextStyle:se,cancelButtonStyle:de,cancelButtonTextStyle:ce},ye)=>{let L=new Date().getFullYear(),w=useRef(null),H=useMemo(()=>k||(l?"dd MMM yyyy HH:mm":"dd MMMM yyyy"),[k,l]),[V,_]=useState("01"),[f,v]=useState("January"),[T,j]=useState(L),[U,O]=useState([]),[G,ue]=useState([]),[ge,he]=useState(false),[P,q]=useState("00"),[A,K]=useState("00"),[b,pe]=useState(180),Q=l?Ne:m,W=useCallback(e=>{let o;if(e)try{o=parse(e,H,new Date),(!o||isNaN(o.getTime()))&&(o=new Date);}catch{o=new Date;}else o=new Date;let s=format(o,"dd"),d=o.getMonth(),y=m[d],u=getYear(o),z=h?parse(h,"yyyy-MM-dd",new Date):subYears(new Date,200),we=x?parse(x,"yyyy-MM-dd",new Date):new Date,Te=Array.from({length:200},(E,Be)=>L-Be).filter(E=>E>=getYear(z)&&E<=getYear(we)),Me=getDaysInMonth(new Date(u,d)),Ce=N(Me);_(s),v(y),j(u),ue(Te),O(Ce),q(format(o,"HH")),K(format(o,"mm")),he(true),setTimeout(()=>w.current?.present(),10);},[h,x,l,H]);useImperativeHandle(ye,()=>({show:W}),[W]);let fe=()=>{let e=m.findIndex(z=>z===f),o=`${T}-${(e+1).toString().padStart(2,"0")}-${V}`,s=l?parse(`${o} ${P}:${A}`,"yyyy-MM-dd HH:mm",new Date):parse(o,"yyyy-MM-dd",new Date),d=h?startOfDay(parse(h,"yyyy-MM-dd",new Date)):null,y=x?startOfDay(parse(x,"yyyy-MM-dd",new Date)):null;if(d&&isBefore(startOfDay(s),d)||y&&isAfter(startOfDay(s),y))return;let u=format(s,H);B(u),w.current?.close();},me=e=>{let o=l?m.find(u=>u.startsWith(e))??e:e,s=m.findIndex(u=>u===o),d=getDaysInMonth(new Date(T,s)),y=N(d);v(o),O(y);},xe=e=>{let o=m.findIndex(y=>y===f),s=getDaysInMonth(new Date(e,o)),d=N(s);j(e),O(d);},Se=U.findIndex(e=>e===V),be=Q.findIndex(e=>l?f.startsWith(e):e===f),De=G.findIndex(e=>e===T),Fe=useMemo(()=>r||g||"Select Date",[r,g]),Ie=e=>{pe(e?.nativeEvent?.layout?.height||180);};return t.createElement(t.Fragment,null,t.createElement(View,{style:n.container},i&&t.createElement(Text,{style:[n.label,re]},i),J&&t.createElement(Text,{style:[n.subText,le]},J),t.createElement(TouchableOpacity,{style:[n.input,I&&n.inputError,ne],onPress:()=>W(r)},t.createElement(Text,{style:[n.inputText,!r&&n.inputTextPlaceholder,oe]},Fe)),I&&I.length>0&&t.createElement(Text,{style:[n.errorText,ae]},I[0])),t.createElement(BottomSheetModal,{ref:w,snapPoints:["50%"],backgroundStyle:{backgroundColor:"#fff"},enableDynamicSizing:false,backdropComponent:e=>t.createElement(BottomSheetBackdrop,{...e,disappearsOnIndex:-1,appearsOnIndex:0}),enableContentPanningGesture:false,enableHandlePanningGesture:false,enablePanDownToClose:false},ge&&t.createElement(View,{style:n.modalContent},t.createElement(View,null,t.createElement(Text,{style:n.modalTitle},"Select Date ",l?"& Time":"")),t.createElement(View,{style:n.pickerContainer,onLayout:Ie},t.createElement(F,{dataSource:U,selectedIndex:Se,renderItem:e=>t.createElement(Text,{style:e===V?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>_(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}),t.createElement(F,{dataSource:Q,selectedIndex:be,renderItem:e=>t.createElement(Text,{style:e===(l?f.slice(0,3):f)?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>me(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}),t.createElement(F,{dataSource:G,selectedIndex:De,renderItem:e=>t.createElement(Text,{style:e===T?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>xe(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}),l&&t.createElement(t.Fragment,null,t.createElement(F,{dataSource:Z,selectedIndex:Z.findIndex(e=>e===P),renderItem:e=>t.createElement(Text,{style:e===P?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>q(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}),t.createElement(F,{dataSource:R,selectedIndex:R.findIndex(e=>e===A),renderItem:e=>t.createElement(Text,{style:e===A?n.pickerItemBold:n.pickerItem},e),onValueChange:e=>K(e),wrapperHeight:b,itemHeight:40,highlightBorderWidth:.5,highlightColor:S,wrapperBackground:"#FFFFFF"}))),t.createElement(View,{style:[n.buttonContainer,{paddingBottom:(Platform.OS==="ios",20)}]},t.createElement(ee,{onPress:()=>w.current?.close(),outline:true,style:de,textStyle:ce},"Cancel"),t.createElement(ee,{onPress:fe,style:ie,textStyle:se},"Save")))))}),n=StyleSheet.create({container:{flexDirection:"column",gap:8},label:{fontSize:14,color:"#6B7280"},subText:{fontSize:14,color:"#6B7280",width:"95%"},input:{fontSize:16,color:"#000",backgroundColor:"#F3F4F6",borderRadius:16,padding:14,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.1,shadowRadius:3,elevation:2},inputError:{borderWidth:1,borderColor:"#EF4444"},inputText:{fontSize:16,color:"#1F2937"},inputTextPlaceholder:{color:"#9CA3AF"},errorText:{fontSize:12,color:"#EF4444",fontWeight:"bold"},modalContent:{flexDirection:"column",gap:12,marginHorizontal:24,flex:1},modalTitle:{fontSize:20,fontWeight:"bold",color:"#1F2937"},pickerContainer:{flexDirection:"row",justifyContent:"space-between",paddingVertical:16,flex:1},pickerItem:{fontSize:16,color:"#1F2937"},pickerItemBold:{fontSize:16,color:"#1F2937",fontWeight:"bold"},buttonContainer:{flexDirection:"row",justifyContent:"space-between",gap:24,paddingVertical:16,backgroundColor:"#fff"},button:{flex:1,backgroundColor:"#3B82F6",borderRadius:12,paddingVertical:14,paddingHorizontal:20,alignItems:"center",justifyContent:"center"},buttonOutline:{backgroundColor:"transparent",borderWidth:1,borderColor:"#3B82F6"},buttonText:{color:"#fff",fontSize:16,fontWeight:"600"},buttonTextOutline:{color:"#3B82F6"}}),Le=Je;export{Le as DatePicker};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.0.1",
6
+ "version": "1.0.3",
7
7
  "description": "A flexible and customizable React Native datepicker component with bottom sheet modal",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.mjs",
@@ -38,13 +38,14 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "react": ">=16.8.0",
41
- "react-native": ">=0.60.0"
41
+ "react-native": ">=0.60.0",
42
+ "@gorhom/bottom-sheet": ">=4.0.0",
43
+ "react-native-gesture-handler": ">=2.0.0",
44
+ "react-native-reanimated": ">=2.0.0",
45
+ "react-native-safe-area-context": ">=4.0.0"
42
46
  },
43
47
  "dependencies": {
44
- "@gorhom/bottom-sheet": "^4.6.3",
45
- "classnames": "^2.5.1",
46
48
  "date-fns": "^3.3.1",
47
- "react-native-safe-area-context": "^4.10.0",
48
49
  "react-native-wheel-scrollview-picker": "^2.0.1"
49
50
  },
50
51
  "devDependencies": {
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.tsx","../src/DatePicker.tsx"],"sourcesContent":["export { default as DatePicker } from \"./DatePicker\";\nexport type { DatePickerRef, DatePickerProps } from \"./DatePicker\";\n","import React, {\n useState,\n useImperativeHandle,\n forwardRef,\n useCallback,\n useRef,\n useMemo,\n} from \"react\";\nimport {\n View,\n TouchableOpacity,\n Platform,\n LayoutChangeEvent,\n Text,\n StyleSheet,\n ViewStyle,\n TextStyle,\n} from \"react-native\";\nimport {\n format,\n parse,\n getDaysInMonth,\n subYears,\n isBefore,\n isAfter,\n getYear,\n startOfDay,\n} from \"date-fns\";\nimport ScrollPicker from \"react-native-wheel-scrollview-picker\";\nimport { BottomSheetModal, BottomSheetBackdrop } from \"@gorhom/bottom-sheet\";\nimport { useSafeAreaInsets } from \"react-native-safe-area-context\";\n\nexport interface DatePickerRef {\n show: (initialDate?: string) => void;\n}\n\nexport interface DatePickerProps {\n value?: string;\n label?: string;\n placeholder?: string;\n onChange: (date: string) => void;\n minDate?: string;\n maxDate?: string;\n showTimePicker?: boolean;\n subText?: string | React.ReactNode;\n errors?: string[];\n // Styling props\n inputStyle?: ViewStyle;\n inputTextStyle?: TextStyle;\n labelStyle?: TextStyle;\n errorStyle?: TextStyle;\n subTextStyle?: TextStyle;\n highlightColor?: string;\n buttonStyle?: ViewStyle;\n buttonTextStyle?: TextStyle;\n cancelButtonStyle?: ViewStyle;\n cancelButtonTextStyle?: TextStyle;\n}\n\nconst InternalButton: React.FC<{\n onPress: () => void;\n children: string;\n outline?: boolean;\n style?: ViewStyle;\n textStyle?: TextStyle;\n}> = ({ onPress, children, outline, style, textStyle }) => {\n return (\n <TouchableOpacity\n onPress={onPress}\n style={[styles.button, outline && styles.buttonOutline, style]}\n >\n <Text\n style={[\n styles.buttonText,\n outline && styles.buttonTextOutline,\n textStyle,\n ]}\n >\n {children}\n </Text>\n </TouchableOpacity>\n );\n};\n\nconst DatePicker = forwardRef<DatePickerRef, DatePickerProps>(\n (\n {\n value,\n label,\n placeholder,\n onChange,\n minDate,\n maxDate,\n showTimePicker = false,\n subText,\n errors,\n inputStyle,\n inputTextStyle,\n labelStyle,\n errorStyle,\n subTextStyle,\n highlightColor = \"#E5E5E5\",\n buttonStyle,\n buttonTextStyle,\n cancelButtonStyle,\n cancelButtonTextStyle,\n },\n ref\n ) => {\n const nowYear = new Date().getFullYear();\n const bottomSheetRef = useRef<BottomSheetModal>(null);\n const { bottom: paddingBottom } = useSafeAreaInsets();\n\n const fullMonths = useMemo(\n () => [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\",\n ],\n []\n );\n\n const shortMonths = useMemo(\n () => [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\",\n ],\n []\n );\n const [day, setDay] = useState(\"01\");\n const [month, setMonth] = useState(\"January\");\n const [year, setYear] = useState(nowYear);\n const [days, setDays] = useState<string[]>([]);\n const [years, setYears] = useState<number[]>([]);\n const [initComplete, setInitComplete] = useState(false);\n const [hour, setHour] = useState(\"00\");\n const [minute, setMinute] = useState(\"00\");\n const [height, setHeight] = useState(180);\n\n const displayMonths = showTimePicker ? shortMonths : fullMonths;\n\n const show = useCallback(\n (initialDate?: string) => {\n const selectedDate = initialDate\n ? parse(initialDate, \"yyyy-MM-dd\", new Date())\n : new Date();\n const selectedDay = format(selectedDate, \"dd\");\n const currentMonthIndex = selectedDate.getMonth();\n const selectedMonth = fullMonths[currentMonthIndex];\n const selectedYear = getYear(selectedDate);\n\n const min = minDate\n ? parse(minDate, \"yyyy-MM-dd\", new Date())\n : subYears(new Date(), 200);\n const max = maxDate\n ? parse(maxDate, \"yyyy-MM-dd\", new Date())\n : new Date();\n\n const allYears = Array.from(\n { length: 200 },\n (_, i) => nowYear - i\n ).filter((y) => y >= getYear(min) && y <= getYear(max));\n\n const totalDays = getDaysInMonth(\n new Date(selectedYear, currentMonthIndex)\n );\n const daysArray = Array.from({ length: totalDays }, (_, i) =>\n `${i + 1}`.padStart(2, \"0\")\n );\n\n setDay(selectedDay);\n setMonth(selectedMonth);\n setYear(selectedYear);\n setYears(allYears);\n setDays(daysArray);\n setHour(format(selectedDate, \"HH\"));\n setMinute(format(selectedDate, \"mm\"));\n setInitComplete(true);\n\n setTimeout(() => bottomSheetRef.current?.present(), 10);\n },\n [minDate, maxDate, fullMonths]\n );\n\n useImperativeHandle(ref, () => ({ show }), [show]);\n\n const handleSetDate = () => {\n const monthIndex = fullMonths.findIndex((m) => m === month);\n const finalDateStr = `${year}-${(monthIndex + 1)\n .toString()\n .padStart(2, \"0\")}-${day}`;\n\n const finalDate = showTimePicker\n ? parse(\n `${finalDateStr} ${hour}:${minute}`,\n \"yyyy-MM-dd HH:mm\",\n new Date()\n )\n : parse(finalDateStr, \"yyyy-MM-dd\", new Date());\n\n const minDateTime = minDate\n ? startOfDay(parse(minDate, \"yyyy-MM-dd\", new Date()))\n : null;\n const maxDateTime = maxDate\n ? startOfDay(parse(maxDate, \"yyyy-MM-dd\", new Date()))\n : null;\n\n if (\n (minDateTime && isBefore(startOfDay(finalDate), minDateTime)) ||\n (maxDateTime && isAfter(startOfDay(finalDate), maxDateTime))\n ) {\n return;\n }\n\n const selectedMonthIndex = fullMonths.findIndex((m) => m === month);\n const formattedDate = showTimePicker\n ? `${day} ${shortMonths[selectedMonthIndex]} ${year} ${hour}:${minute}`\n : `${day} ${fullMonths[selectedMonthIndex]} ${year}`;\n\n onChange(formattedDate);\n bottomSheetRef.current?.close();\n };\n\n const handleMonthChange = (val: string) => {\n const fullMonth = showTimePicker\n ? (fullMonths.find((m) => m.startsWith(val)) ?? val)\n : val;\n const changedMonthIndex = fullMonths.findIndex((m) => m === fullMonth);\n const totalDays = getDaysInMonth(new Date(year, changedMonthIndex));\n const newDays = Array.from({ length: totalDays }, (_, i) =>\n `${i + 1}`.padStart(2, \"0\")\n );\n setMonth(fullMonth);\n setDays(newDays);\n };\n\n const handleYearChange = (val: number) => {\n const yearMonthIndex = fullMonths.findIndex((m) => m === month);\n const totalDays = getDaysInMonth(new Date(val, yearMonthIndex));\n const newDays = Array.from({ length: totalDays }, (_, i) =>\n `${i + 1}`.padStart(2, \"0\")\n );\n setYear(val);\n setDays(newDays);\n };\n\n const findSelectedDayByIndex = days.findIndex((val) => val === day);\n const findSelectedMonthByIndex = displayMonths.findIndex((val) =>\n showTimePicker ? month.startsWith(val) : val === month\n );\n const findSelectedYearByIndex = years.findIndex((val) => val === year);\n const hours = Array.from({ length: 24 }, (_, i) => `${i}`.padStart(2, \"0\"));\n const minutes = Array.from({ length: 60 }, (_, i) =>\n `${i}`.padStart(2, \"0\")\n );\n\n const dateValue = useMemo(() => {\n if (value) {\n return value;\n }\n return placeholder || \"Select Date\";\n }, [value, placeholder]);\n\n const handleLayout = (e?: LayoutChangeEvent) => {\n setHeight(e?.nativeEvent?.layout?.height || 180);\n };\n\n return (\n <>\n <View style={styles.container}>\n {label && <Text style={[styles.label, labelStyle]}>{label}</Text>}\n {subText && (\n <Text style={[styles.subText, subTextStyle]}>{subText}</Text>\n )}\n <TouchableOpacity\n style={[styles.input, errors && styles.inputError, inputStyle]}\n onPress={() => show(value)}\n >\n <Text\n style={[\n styles.inputText,\n !value && styles.inputTextPlaceholder,\n inputTextStyle,\n ]}\n >\n {dateValue}\n </Text>\n </TouchableOpacity>\n {errors && errors.length > 0 && (\n <Text style={[styles.errorText, errorStyle]}>{errors[0]}</Text>\n )}\n </View>\n\n <BottomSheetModal\n ref={bottomSheetRef}\n snapPoints={[\"50%\"]}\n backgroundStyle={{ backgroundColor: \"#fff\" }}\n enableDynamicSizing={false}\n backdropComponent={(props) => (\n <BottomSheetBackdrop\n {...props}\n disappearsOnIndex={-1}\n appearsOnIndex={0}\n />\n )}\n enableContentPanningGesture={false}\n enableHandlePanningGesture={false}\n enablePanDownToClose={false}\n >\n {initComplete && (\n <View style={styles.modalContent}>\n <View>\n <Text style={styles.modalTitle}>\n Select Date {showTimePicker ? \"& Time\" : \"\"}\n </Text>\n </View>\n <View style={styles.pickerContainer} onLayout={handleLayout}>\n {/* Day */}\n <ScrollPicker\n dataSource={days}\n selectedIndex={findSelectedDayByIndex}\n renderItem={(data) => (\n <Text\n style={\n data === day ? styles.pickerItemBold : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => setDay(value as string)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n {/* Month */}\n <ScrollPicker\n dataSource={displayMonths}\n selectedIndex={findSelectedMonthByIndex}\n renderItem={(data) => (\n <Text\n style={\n data === (showTimePicker ? month.slice(0, 3) : month)\n ? styles.pickerItemBold\n : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => handleMonthChange(value as string)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n {/* Year */}\n <ScrollPicker\n dataSource={years}\n selectedIndex={findSelectedYearByIndex}\n renderItem={(data) => (\n <Text\n style={\n data === year\n ? styles.pickerItemBold\n : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => handleYearChange(value as number)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n {showTimePicker && (\n <>\n <ScrollPicker\n dataSource={hours}\n selectedIndex={hours.findIndex((val) => val === hour)}\n renderItem={(data) => (\n <Text\n style={\n data === hour\n ? styles.pickerItemBold\n : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => setHour(value as string)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n <ScrollPicker\n dataSource={minutes}\n selectedIndex={minutes.findIndex((val) => val === minute)}\n renderItem={(data) => (\n <Text\n style={\n data === minute\n ? styles.pickerItemBold\n : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => setMinute(value as string)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n </>\n )}\n </View>\n <View\n style={[\n styles.buttonContainer,\n {\n paddingBottom: Platform.OS === \"ios\" ? paddingBottom : 20,\n },\n ]}\n >\n <InternalButton\n onPress={() => bottomSheetRef.current?.close()}\n outline\n style={cancelButtonStyle}\n textStyle={cancelButtonTextStyle}\n >\n Cancel\n </InternalButton>\n <InternalButton\n onPress={handleSetDate}\n style={buttonStyle}\n textStyle={buttonTextStyle}\n >\n Save\n </InternalButton>\n </View>\n </View>\n )}\n </BottomSheetModal>\n </>\n );\n }\n);\n\nconst styles = StyleSheet.create({\n container: {\n flexDirection: \"column\",\n gap: 8,\n },\n label: {\n fontSize: 14,\n color: \"#6B7280\",\n },\n subText: {\n fontSize: 14,\n color: \"#6B7280\",\n width: \"95%\",\n },\n input: {\n fontSize: 16,\n color: \"#000\",\n backgroundColor: \"#F3F4F6\",\n borderRadius: 16,\n padding: 14,\n shadowColor: \"#000\",\n shadowOffset: {\n width: 0,\n height: 2,\n },\n shadowOpacity: 0.1,\n shadowRadius: 3,\n elevation: 2,\n },\n inputError: {\n borderWidth: 1,\n borderColor: \"#EF4444\",\n },\n inputText: {\n fontSize: 16,\n color: \"#1F2937\",\n },\n inputTextPlaceholder: {\n color: \"#9CA3AF\",\n },\n errorText: {\n fontSize: 12,\n color: \"#EF4444\",\n fontWeight: \"bold\",\n },\n modalContent: {\n flexDirection: \"column\",\n gap: 12,\n marginHorizontal: 24,\n flex: 1,\n },\n modalTitle: {\n fontSize: 20,\n fontWeight: \"bold\",\n color: \"#1F2937\",\n },\n pickerContainer: {\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingVertical: 16,\n flex: 1,\n },\n pickerItem: {\n fontSize: 16,\n color: \"#1F2937\",\n },\n pickerItemBold: {\n fontSize: 16,\n color: \"#1F2937\",\n fontWeight: \"bold\",\n },\n buttonContainer: {\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n gap: 24,\n paddingVertical: 16,\n backgroundColor: \"#fff\",\n },\n button: {\n flex: 1,\n backgroundColor: \"#3B82F6\",\n borderRadius: 12,\n paddingVertical: 14,\n paddingHorizontal: 20,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n buttonOutline: {\n backgroundColor: \"transparent\",\n borderWidth: 1,\n borderColor: \"#3B82F6\",\n },\n buttonText: {\n color: \"#fff\",\n fontSize: 16,\n fontWeight: \"600\",\n },\n buttonTextOutline: {\n color: \"#3B82F6\",\n },\n});\n\nexport default DatePicker;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAOO;AACP,0BASO;AACP,sBASO;AACP,kDAAyB;AACzB,0BAAsD;AACtD,4CAAkC;AA6BlC,IAAM,iBAMD,CAAC,EAAE,SAAS,UAAU,SAAS,OAAO,UAAU,MAAM;AACzD,SACE,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO,CAAC,OAAO,QAAQ,WAAW,OAAO,eAAe,KAAK;AAAA;AAAA,IAE7D,6BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,UACL,OAAO;AAAA,UACP,WAAW,OAAO;AAAA,UAClB;AAAA,QACF;AAAA;AAAA,MAEC;AAAA,IACH;AAAA,EACF;AAEJ;AAEA,IAAM,iBAAa;AAAA,EACjB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GACA,QACG;AACH,UAAM,WAAU,oBAAI,KAAK,GAAE,YAAY;AACvC,UAAM,qBAAiB,qBAAyB,IAAI;AACpD,UAAM,EAAE,QAAQ,cAAc,QAAI,yDAAkB;AAEpD,UAAM,iBAAa;AAAA,MACjB,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,CAAC;AAA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A,EACf;AAAA,EACA,WAAW;AAAA,IACT,UAAU;AAAA,IACV,OAAO;AAAA,EACT;AAAA,EACA,sBAAsB;AAAA,IACpB,OAAO;AAAA,EACT;AAAA,EACA,WAAW;AAAA,IACT,UAAU;AAAA,IACV,OAAO;AAAA,IACP,YAAY;AAAA,EACd;AAAA,EACA,cAAc;AAAA,IACZ,eAAe;AAAA,IACf,KAAK;AAAA,IACL,kBAAkB;AAAA,IAClB,MAAM;AAAA,EACR;AAAA,EACA,YAAY;AAAA,IACV,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,EACT;AAAA,EACA,iBAAiB;AAAA,IACf,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,MAAM;AAAA,EACR;AAAA,EACA,YAAY;AAAA,IACV,UAAU;AAAA,IACV,OAAO;AAAA,EACT;AAAA,EACA,gBAAgB;AAAA,IACd,UAAU;AAAA,IACV,OAAO;AAAA,IACP,YAAY;AAAA,EACd;AAAA,EACA,iBAAiB;AAAA,IACf,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,KAAK;AAAA,IACL,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,EACnB;AAAA,EACA,QAAQ;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB,YAAY;AAAA,IACZ,gBAAgB;AAAA,EAClB;AAAA,EACA,eAAe;AAAA,IACb,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,aAAa;AAAA,EACf;AAAA,EACA,YAAY;AAAA,IACV,OAAO;AAAA,IACP,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAAA,EACA,mBAAmB;AAAA,IACjB,OAAO;AAAA,EACT;AACF,CAAC;AAED,IAAO,qBAAQ;","names":["React","ScrollPicker","value"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/DatePicker.tsx"],"sourcesContent":["import React, {\n useState,\n useImperativeHandle,\n forwardRef,\n useCallback,\n useRef,\n useMemo,\n} from \"react\";\nimport {\n View,\n TouchableOpacity,\n Platform,\n LayoutChangeEvent,\n Text,\n StyleSheet,\n ViewStyle,\n TextStyle,\n} from \"react-native\";\nimport {\n format,\n parse,\n getDaysInMonth,\n subYears,\n isBefore,\n isAfter,\n getYear,\n startOfDay,\n} from \"date-fns\";\nimport ScrollPicker from \"react-native-wheel-scrollview-picker\";\nimport { BottomSheetModal, BottomSheetBackdrop } from \"@gorhom/bottom-sheet\";\nimport { useSafeAreaInsets } from \"react-native-safe-area-context\";\n\nexport interface DatePickerRef {\n show: (initialDate?: string) => void;\n}\n\nexport interface DatePickerProps {\n value?: string;\n label?: string;\n placeholder?: string;\n onChange: (date: string) => void;\n minDate?: string;\n maxDate?: string;\n showTimePicker?: boolean;\n subText?: string | React.ReactNode;\n errors?: string[];\n // Styling props\n inputStyle?: ViewStyle;\n inputTextStyle?: TextStyle;\n labelStyle?: TextStyle;\n errorStyle?: TextStyle;\n subTextStyle?: TextStyle;\n highlightColor?: string;\n buttonStyle?: ViewStyle;\n buttonTextStyle?: TextStyle;\n cancelButtonStyle?: ViewStyle;\n cancelButtonTextStyle?: TextStyle;\n}\n\nconst InternalButton: React.FC<{\n onPress: () => void;\n children: string;\n outline?: boolean;\n style?: ViewStyle;\n textStyle?: TextStyle;\n}> = ({ onPress, children, outline, style, textStyle }) => {\n return (\n <TouchableOpacity\n onPress={onPress}\n style={[styles.button, outline && styles.buttonOutline, style]}\n >\n <Text\n style={[\n styles.buttonText,\n outline && styles.buttonTextOutline,\n textStyle,\n ]}\n >\n {children}\n </Text>\n </TouchableOpacity>\n );\n};\n\nconst DatePicker = forwardRef<DatePickerRef, DatePickerProps>(\n (\n {\n value,\n label,\n placeholder,\n onChange,\n minDate,\n maxDate,\n showTimePicker = false,\n subText,\n errors,\n inputStyle,\n inputTextStyle,\n labelStyle,\n errorStyle,\n subTextStyle,\n highlightColor = \"#E5E5E5\",\n buttonStyle,\n buttonTextStyle,\n cancelButtonStyle,\n cancelButtonTextStyle,\n },\n ref\n ) => {\n const nowYear = new Date().getFullYear();\n const bottomSheetRef = useRef<BottomSheetModal>(null);\n const { bottom: paddingBottom } = useSafeAreaInsets();\n\n const fullMonths = useMemo(\n () => [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\",\n ],\n []\n );\n\n const shortMonths = useMemo(\n () => [\n \"Jan\",\n \"Feb\",\n \"Mar\",\n \"Apr\",\n \"May\",\n \"Jun\",\n \"Jul\",\n \"Aug\",\n \"Sep\",\n \"Oct\",\n \"Nov\",\n \"Dec\",\n ],\n []\n );\n const [day, setDay] = useState(\"01\");\n const [month, setMonth] = useState(\"January\");\n const [year, setYear] = useState(nowYear);\n const [days, setDays] = useState<string[]>([]);\n const [years, setYears] = useState<number[]>([]);\n const [initComplete, setInitComplete] = useState(false);\n const [hour, setHour] = useState(\"00\");\n const [minute, setMinute] = useState(\"00\");\n const [height, setHeight] = useState(180);\n\n const displayMonths = showTimePicker ? shortMonths : fullMonths;\n\n const show = useCallback(\n (initialDate?: string) => {\n const selectedDate = initialDate\n ? parse(initialDate, \"yyyy-MM-dd\", new Date())\n : new Date();\n const selectedDay = format(selectedDate, \"dd\");\n const currentMonthIndex = selectedDate.getMonth();\n const selectedMonth = fullMonths[currentMonthIndex];\n const selectedYear = getYear(selectedDate);\n\n const min = minDate\n ? parse(minDate, \"yyyy-MM-dd\", new Date())\n : subYears(new Date(), 200);\n const max = maxDate\n ? parse(maxDate, \"yyyy-MM-dd\", new Date())\n : new Date();\n\n const allYears = Array.from(\n { length: 200 },\n (_, i) => nowYear - i\n ).filter((y) => y >= getYear(min) && y <= getYear(max));\n\n const totalDays = getDaysInMonth(\n new Date(selectedYear, currentMonthIndex)\n );\n const daysArray = Array.from({ length: totalDays }, (_, i) =>\n `${i + 1}`.padStart(2, \"0\")\n );\n\n setDay(selectedDay);\n setMonth(selectedMonth);\n setYear(selectedYear);\n setYears(allYears);\n setDays(daysArray);\n setHour(format(selectedDate, \"HH\"));\n setMinute(format(selectedDate, \"mm\"));\n setInitComplete(true);\n\n setTimeout(() => bottomSheetRef.current?.present(), 10);\n },\n [minDate, maxDate, fullMonths]\n );\n\n useImperativeHandle(ref, () => ({ show }), [show]);\n\n const handleSetDate = () => {\n const monthIndex = fullMonths.findIndex((m) => m === month);\n const finalDateStr = `${year}-${(monthIndex + 1)\n .toString()\n .padStart(2, \"0\")}-${day}`;\n\n const finalDate = showTimePicker\n ? parse(\n `${finalDateStr} ${hour}:${minute}`,\n \"yyyy-MM-dd HH:mm\",\n new Date()\n )\n : parse(finalDateStr, \"yyyy-MM-dd\", new Date());\n\n const minDateTime = minDate\n ? startOfDay(parse(minDate, \"yyyy-MM-dd\", new Date()))\n : null;\n const maxDateTime = maxDate\n ? startOfDay(parse(maxDate, \"yyyy-MM-dd\", new Date()))\n : null;\n\n if (\n (minDateTime && isBefore(startOfDay(finalDate), minDateTime)) ||\n (maxDateTime && isAfter(startOfDay(finalDate), maxDateTime))\n ) {\n return;\n }\n\n const selectedMonthIndex = fullMonths.findIndex((m) => m === month);\n const formattedDate = showTimePicker\n ? `${day} ${shortMonths[selectedMonthIndex]} ${year} ${hour}:${minute}`\n : `${day} ${fullMonths[selectedMonthIndex]} ${year}`;\n\n onChange(formattedDate);\n bottomSheetRef.current?.close();\n };\n\n const handleMonthChange = (val: string) => {\n const fullMonth = showTimePicker\n ? (fullMonths.find((m) => m.startsWith(val)) ?? val)\n : val;\n const changedMonthIndex = fullMonths.findIndex((m) => m === fullMonth);\n const totalDays = getDaysInMonth(new Date(year, changedMonthIndex));\n const newDays = Array.from({ length: totalDays }, (_, i) =>\n `${i + 1}`.padStart(2, \"0\")\n );\n setMonth(fullMonth);\n setDays(newDays);\n };\n\n const handleYearChange = (val: number) => {\n const yearMonthIndex = fullMonths.findIndex((m) => m === month);\n const totalDays = getDaysInMonth(new Date(val, yearMonthIndex));\n const newDays = Array.from({ length: totalDays }, (_, i) =>\n `${i + 1}`.padStart(2, \"0\")\n );\n setYear(val);\n setDays(newDays);\n };\n\n const findSelectedDayByIndex = days.findIndex((val) => val === day);\n const findSelectedMonthByIndex = displayMonths.findIndex((val) =>\n showTimePicker ? month.startsWith(val) : val === month\n );\n const findSelectedYearByIndex = years.findIndex((val) => val === year);\n const hours = Array.from({ length: 24 }, (_, i) => `${i}`.padStart(2, \"0\"));\n const minutes = Array.from({ length: 60 }, (_, i) =>\n `${i}`.padStart(2, \"0\")\n );\n\n const dateValue = useMemo(() => {\n if (value) {\n return value;\n }\n return placeholder || \"Select Date\";\n }, [value, placeholder]);\n\n const handleLayout = (e?: LayoutChangeEvent) => {\n setHeight(e?.nativeEvent?.layout?.height || 180);\n };\n\n return (\n <>\n <View style={styles.container}>\n {label && <Text style={[styles.label, labelStyle]}>{label}</Text>}\n {subText && (\n <Text style={[styles.subText, subTextStyle]}>{subText}</Text>\n )}\n <TouchableOpacity\n style={[styles.input, errors && styles.inputError, inputStyle]}\n onPress={() => show(value)}\n >\n <Text\n style={[\n styles.inputText,\n !value && styles.inputTextPlaceholder,\n inputTextStyle,\n ]}\n >\n {dateValue}\n </Text>\n </TouchableOpacity>\n {errors && errors.length > 0 && (\n <Text style={[styles.errorText, errorStyle]}>{errors[0]}</Text>\n )}\n </View>\n\n <BottomSheetModal\n ref={bottomSheetRef}\n snapPoints={[\"50%\"]}\n backgroundStyle={{ backgroundColor: \"#fff\" }}\n enableDynamicSizing={false}\n backdropComponent={(props) => (\n <BottomSheetBackdrop\n {...props}\n disappearsOnIndex={-1}\n appearsOnIndex={0}\n />\n )}\n enableContentPanningGesture={false}\n enableHandlePanningGesture={false}\n enablePanDownToClose={false}\n >\n {initComplete && (\n <View style={styles.modalContent}>\n <View>\n <Text style={styles.modalTitle}>\n Select Date {showTimePicker ? \"& Time\" : \"\"}\n </Text>\n </View>\n <View style={styles.pickerContainer} onLayout={handleLayout}>\n {/* Day */}\n <ScrollPicker\n dataSource={days}\n selectedIndex={findSelectedDayByIndex}\n renderItem={(data) => (\n <Text\n style={\n data === day ? styles.pickerItemBold : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => setDay(value as string)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n {/* Month */}\n <ScrollPicker\n dataSource={displayMonths}\n selectedIndex={findSelectedMonthByIndex}\n renderItem={(data) => (\n <Text\n style={\n data === (showTimePicker ? month.slice(0, 3) : month)\n ? styles.pickerItemBold\n : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => handleMonthChange(value as string)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n {/* Year */}\n <ScrollPicker\n dataSource={years}\n selectedIndex={findSelectedYearByIndex}\n renderItem={(data) => (\n <Text\n style={\n data === year\n ? styles.pickerItemBold\n : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => handleYearChange(value as number)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n {showTimePicker && (\n <>\n <ScrollPicker\n dataSource={hours}\n selectedIndex={hours.findIndex((val) => val === hour)}\n renderItem={(data) => (\n <Text\n style={\n data === hour\n ? styles.pickerItemBold\n : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => setHour(value as string)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n <ScrollPicker\n dataSource={minutes}\n selectedIndex={minutes.findIndex((val) => val === minute)}\n renderItem={(data) => (\n <Text\n style={\n data === minute\n ? styles.pickerItemBold\n : styles.pickerItem\n }\n >\n {data}\n </Text>\n )}\n onValueChange={(value) => setMinute(value as string)}\n wrapperHeight={height}\n itemHeight={40}\n highlightBorderWidth={0.5}\n highlightColor={highlightColor}\n wrapperBackground=\"#FFFFFF\"\n />\n </>\n )}\n </View>\n <View\n style={[\n styles.buttonContainer,\n {\n paddingBottom: Platform.OS === \"ios\" ? paddingBottom : 20,\n },\n ]}\n >\n <InternalButton\n onPress={() => bottomSheetRef.current?.close()}\n outline\n style={cancelButtonStyle}\n textStyle={cancelButtonTextStyle}\n >\n Cancel\n </InternalButton>\n <InternalButton\n onPress={handleSetDate}\n style={buttonStyle}\n textStyle={buttonTextStyle}\n >\n Save\n </InternalButton>\n </View>\n </View>\n )}\n </BottomSheetModal>\n </>\n );\n }\n);\n\nconst styles = StyleSheet.create({\n container: {\n flexDirection: \"column\",\n gap: 8,\n },\n label: {\n fontSize: 14,\n color: \"#6B7280\",\n },\n subText: {\n fontSize: 14,\n color: \"#6B7280\",\n width: \"95%\",\n },\n input: {\n fontSize: 16,\n color: \"#000\",\n backgroundColor: \"#F3F4F6\",\n borderRadius: 16,\n padding: 14,\n shadowColor: \"#000\",\n shadowOffset: {\n width: 0,\n height: 2,\n },\n shadowOpacity: 0.1,\n shadowRadius: 3,\n elevation: 2,\n },\n inputError: {\n borderWidth: 1,\n borderColor: \"#EF4444\",\n },\n inputText: {\n fontSize: 16,\n color: \"#1F2937\",\n },\n inputTextPlaceholder: {\n color: \"#9CA3AF\",\n },\n errorText: {\n fontSize: 12,\n color: \"#EF4444\",\n fontWeight: \"bold\",\n },\n modalContent: {\n flexDirection: \"column\",\n gap: 12,\n marginHorizontal: 24,\n flex: 1,\n },\n modalTitle: {\n fontSize: 20,\n fontWeight: \"bold\",\n color: \"#1F2937\",\n },\n pickerContainer: {\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n paddingVertical: 16,\n flex: 1,\n },\n pickerItem: {\n fontSize: 16,\n color: \"#1F2937\",\n },\n pickerItemBold: {\n fontSize: 16,\n color: \"#1F2937\",\n fontWeight: \"bold\",\n },\n buttonContainer: {\n flexDirection: \"row\",\n justifyContent: \"space-between\",\n gap: 24,\n paddingVertical: 16,\n backgroundColor: \"#fff\",\n },\n button: {\n flex: 1,\n backgroundColor: \"#3B82F6\",\n borderRadius: 12,\n paddingVertical: 14,\n paddingHorizontal: 20,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n buttonOutline: {\n backgroundColor: \"transparent\",\n borderWidth: 1,\n borderColor: \"#3B82F6\",\n },\n buttonText: {\n color: \"#fff\",\n fontSize: 16,\n fontWeight: \"600\",\n },\n buttonTextOutline: {\n color: \"#3B82F6\",\n },\n});\n\nexport default DatePicker;\n"],"mappings":";AAAA,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,kBAAkB;AACzB,SAAS,kBAAkB,2BAA2B;AACtD,SAAS,yBAAyB;AA6BlC,IAAM,iBAMD,CAAC,EAAE,SAAS,UAAU,SAAS,OAAO,UAAU,MAAM;AACzD,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO,CAAC,OAAO,QAAQ,WAAW,OAAO,eAAe,KAAK;AAAA;AAAA,IAE7D;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,UACL,OAAO;AAAA,UACP,WAAW,OAAO;AAAA,UAClB;AAAA,QACF;AAAA;AAAA,MAEC;AAAA,IACH;AAAA,EACF;AAEJ;AAEA,IAAM,aAAa;AAAA,EACjB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB;AAA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