@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 +21 -0
- package/README.md +203 -0
- package/dist/index.d.mts +30 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +494 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +479 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
- package/src/DatePicker.tsx +582 -0
- package/src/index.tsx +2 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,E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AAU;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":["value"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@purjayadi/react-native-datepicker",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "1.0.0",
|
|
7
|
+
"description": "A flexible and customizable React Native datepicker component with bottom sheet modal",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.mjs",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"src",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup",
|
|
18
|
+
"dev": "tsup --watch",
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"react-native",
|
|
24
|
+
"datepicker",
|
|
25
|
+
"date-picker",
|
|
26
|
+
"timepicker",
|
|
27
|
+
"datetime",
|
|
28
|
+
"bottom-sheet",
|
|
29
|
+
"wheel-picker",
|
|
30
|
+
"ios",
|
|
31
|
+
"android"
|
|
32
|
+
],
|
|
33
|
+
"author": "Purjayadi",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/purjayadi/react-native-datepicker.git"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react": ">=16.8.0",
|
|
41
|
+
"react-native": ">=0.60.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@gorhom/bottom-sheet": "^4.6.3",
|
|
45
|
+
"classnames": "^2.5.1",
|
|
46
|
+
"date-fns": "^3.3.1",
|
|
47
|
+
"react-native-safe-area-context": "^4.10.0",
|
|
48
|
+
"react-native-wheel-scrollview-picker": "^2.0.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/react": "^18.2.79",
|
|
52
|
+
"@types/react-native": "^0.73.0",
|
|
53
|
+
"react": "^18.2.0",
|
|
54
|
+
"react-native": "^0.73.0",
|
|
55
|
+
"tsup": "^8.0.2",
|
|
56
|
+
"typescript": "^5.4.5"
|
|
57
|
+
}
|
|
58
|
+
}
|