@purjayadi/react-native-datepicker 1.0.2 → 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/dist/index.js +1 -508
- package/dist/index.mjs +1 -493
- package/package.json +1 -2
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,508 +1 @@
|
|
|
1
|
-
|
|
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 InternalButton = ({ onPress, children, outline, style, textStyle }) => {
|
|
44
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
45
|
-
import_react_native.TouchableOpacity,
|
|
46
|
-
{
|
|
47
|
-
onPress,
|
|
48
|
-
style: [styles.button, outline && styles.buttonOutline, style]
|
|
49
|
-
},
|
|
50
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
51
|
-
import_react_native.Text,
|
|
52
|
-
{
|
|
53
|
-
style: [
|
|
54
|
-
styles.buttonText,
|
|
55
|
-
outline && styles.buttonTextOutline,
|
|
56
|
-
textStyle
|
|
57
|
-
]
|
|
58
|
-
},
|
|
59
|
-
children
|
|
60
|
-
)
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
var DatePicker = (0, import_react.forwardRef)(
|
|
64
|
-
({
|
|
65
|
-
value,
|
|
66
|
-
label,
|
|
67
|
-
placeholder,
|
|
68
|
-
onChange,
|
|
69
|
-
minDate,
|
|
70
|
-
maxDate,
|
|
71
|
-
showTimePicker = false,
|
|
72
|
-
dateFormat,
|
|
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 defaultFormat = (0, import_react.useMemo)(() => {
|
|
89
|
-
if (dateFormat) return dateFormat;
|
|
90
|
-
return showTimePicker ? "dd MMM yyyy HH:mm" : "dd MMMM yyyy";
|
|
91
|
-
}, [dateFormat, showTimePicker]);
|
|
92
|
-
const fullMonths = (0, import_react.useMemo)(
|
|
93
|
-
() => [
|
|
94
|
-
"January",
|
|
95
|
-
"February",
|
|
96
|
-
"March",
|
|
97
|
-
"April",
|
|
98
|
-
"May",
|
|
99
|
-
"June",
|
|
100
|
-
"July",
|
|
101
|
-
"August",
|
|
102
|
-
"September",
|
|
103
|
-
"October",
|
|
104
|
-
"November",
|
|
105
|
-
"December"
|
|
106
|
-
],
|
|
107
|
-
[]
|
|
108
|
-
);
|
|
109
|
-
const shortMonths = (0, import_react.useMemo)(
|
|
110
|
-
() => [
|
|
111
|
-
"Jan",
|
|
112
|
-
"Feb",
|
|
113
|
-
"Mar",
|
|
114
|
-
"Apr",
|
|
115
|
-
"May",
|
|
116
|
-
"Jun",
|
|
117
|
-
"Jul",
|
|
118
|
-
"Aug",
|
|
119
|
-
"Sep",
|
|
120
|
-
"Oct",
|
|
121
|
-
"Nov",
|
|
122
|
-
"Dec"
|
|
123
|
-
],
|
|
124
|
-
[]
|
|
125
|
-
);
|
|
126
|
-
const [day, setDay] = (0, import_react.useState)("01");
|
|
127
|
-
const [month, setMonth] = (0, import_react.useState)("January");
|
|
128
|
-
const [year, setYear] = (0, import_react.useState)(nowYear);
|
|
129
|
-
const [days, setDays] = (0, import_react.useState)([]);
|
|
130
|
-
const [years, setYears] = (0, import_react.useState)([]);
|
|
131
|
-
const [initComplete, setInitComplete] = (0, import_react.useState)(false);
|
|
132
|
-
const [hour, setHour] = (0, import_react.useState)("00");
|
|
133
|
-
const [minute, setMinute] = (0, import_react.useState)("00");
|
|
134
|
-
const [height, setHeight] = (0, import_react.useState)(180);
|
|
135
|
-
const displayMonths = showTimePicker ? shortMonths : fullMonths;
|
|
136
|
-
const show = (0, import_react.useCallback)(
|
|
137
|
-
(initialDate) => {
|
|
138
|
-
let selectedDate;
|
|
139
|
-
if (initialDate) {
|
|
140
|
-
try {
|
|
141
|
-
selectedDate = (0, import_date_fns.parse)(initialDate, defaultFormat, /* @__PURE__ */ new Date());
|
|
142
|
-
if (!selectedDate || isNaN(selectedDate.getTime())) {
|
|
143
|
-
selectedDate = /* @__PURE__ */ new Date();
|
|
144
|
-
}
|
|
145
|
-
} catch {
|
|
146
|
-
selectedDate = /* @__PURE__ */ new Date();
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
selectedDate = /* @__PURE__ */ new Date();
|
|
150
|
-
}
|
|
151
|
-
const selectedDay = (0, import_date_fns.format)(selectedDate, "dd");
|
|
152
|
-
const currentMonthIndex = selectedDate.getMonth();
|
|
153
|
-
const selectedMonth = fullMonths[currentMonthIndex];
|
|
154
|
-
const selectedYear = (0, import_date_fns.getYear)(selectedDate);
|
|
155
|
-
const min = minDate ? (0, import_date_fns.parse)(minDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : (0, import_date_fns.subYears)(/* @__PURE__ */ new Date(), 200);
|
|
156
|
-
const max = maxDate ? (0, import_date_fns.parse)(maxDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : /* @__PURE__ */ new Date();
|
|
157
|
-
const allYears = Array.from(
|
|
158
|
-
{ length: 200 },
|
|
159
|
-
(_, i) => nowYear - i
|
|
160
|
-
).filter((y) => y >= (0, import_date_fns.getYear)(min) && y <= (0, import_date_fns.getYear)(max));
|
|
161
|
-
const totalDays = (0, import_date_fns.getDaysInMonth)(
|
|
162
|
-
new Date(selectedYear, currentMonthIndex)
|
|
163
|
-
);
|
|
164
|
-
const daysArray = Array.from(
|
|
165
|
-
{ length: totalDays },
|
|
166
|
-
(_, i) => `${i + 1}`.padStart(2, "0")
|
|
167
|
-
);
|
|
168
|
-
setDay(selectedDay);
|
|
169
|
-
setMonth(selectedMonth);
|
|
170
|
-
setYear(selectedYear);
|
|
171
|
-
setYears(allYears);
|
|
172
|
-
setDays(daysArray);
|
|
173
|
-
setHour((0, import_date_fns.format)(selectedDate, "HH"));
|
|
174
|
-
setMinute((0, import_date_fns.format)(selectedDate, "mm"));
|
|
175
|
-
setInitComplete(true);
|
|
176
|
-
setTimeout(() => bottomSheetRef.current?.present(), 10);
|
|
177
|
-
},
|
|
178
|
-
[minDate, maxDate, fullMonths, showTimePicker, defaultFormat]
|
|
179
|
-
);
|
|
180
|
-
(0, import_react.useImperativeHandle)(ref, () => ({ show }), [show]);
|
|
181
|
-
const handleSetDate = () => {
|
|
182
|
-
const monthIndex = fullMonths.findIndex((m) => m === month);
|
|
183
|
-
const finalDateStr = `${year}-${(monthIndex + 1).toString().padStart(2, "0")}-${day}`;
|
|
184
|
-
const finalDate = showTimePicker ? (0, import_date_fns.parse)(
|
|
185
|
-
`${finalDateStr} ${hour}:${minute}`,
|
|
186
|
-
"yyyy-MM-dd HH:mm",
|
|
187
|
-
/* @__PURE__ */ new Date()
|
|
188
|
-
) : (0, import_date_fns.parse)(finalDateStr, "yyyy-MM-dd", /* @__PURE__ */ new Date());
|
|
189
|
-
const minDateTime = minDate ? (0, import_date_fns.startOfDay)((0, import_date_fns.parse)(minDate, "yyyy-MM-dd", /* @__PURE__ */ new Date())) : null;
|
|
190
|
-
const maxDateTime = maxDate ? (0, import_date_fns.startOfDay)((0, import_date_fns.parse)(maxDate, "yyyy-MM-dd", /* @__PURE__ */ new Date())) : null;
|
|
191
|
-
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)) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const formattedDate = (0, import_date_fns.format)(finalDate, defaultFormat);
|
|
195
|
-
onChange(formattedDate);
|
|
196
|
-
bottomSheetRef.current?.close();
|
|
197
|
-
};
|
|
198
|
-
const handleMonthChange = (val) => {
|
|
199
|
-
const fullMonth = showTimePicker ? fullMonths.find((m) => m.startsWith(val)) ?? val : val;
|
|
200
|
-
const changedMonthIndex = fullMonths.findIndex((m) => m === fullMonth);
|
|
201
|
-
const totalDays = (0, import_date_fns.getDaysInMonth)(new Date(year, changedMonthIndex));
|
|
202
|
-
const newDays = Array.from(
|
|
203
|
-
{ length: totalDays },
|
|
204
|
-
(_, i) => `${i + 1}`.padStart(2, "0")
|
|
205
|
-
);
|
|
206
|
-
setMonth(fullMonth);
|
|
207
|
-
setDays(newDays);
|
|
208
|
-
};
|
|
209
|
-
const handleYearChange = (val) => {
|
|
210
|
-
const yearMonthIndex = fullMonths.findIndex((m) => m === month);
|
|
211
|
-
const totalDays = (0, import_date_fns.getDaysInMonth)(new Date(val, yearMonthIndex));
|
|
212
|
-
const newDays = Array.from(
|
|
213
|
-
{ length: totalDays },
|
|
214
|
-
(_, i) => `${i + 1}`.padStart(2, "0")
|
|
215
|
-
);
|
|
216
|
-
setYear(val);
|
|
217
|
-
setDays(newDays);
|
|
218
|
-
};
|
|
219
|
-
const findSelectedDayByIndex = days.findIndex((val) => val === day);
|
|
220
|
-
const findSelectedMonthByIndex = displayMonths.findIndex(
|
|
221
|
-
(val) => showTimePicker ? month.startsWith(val) : val === month
|
|
222
|
-
);
|
|
223
|
-
const findSelectedYearByIndex = years.findIndex((val) => val === year);
|
|
224
|
-
const hours = Array.from({ length: 24 }, (_, i) => `${i}`.padStart(2, "0"));
|
|
225
|
-
const minutes = Array.from(
|
|
226
|
-
{ length: 60 },
|
|
227
|
-
(_, i) => `${i}`.padStart(2, "0")
|
|
228
|
-
);
|
|
229
|
-
const dateValue = (0, import_react.useMemo)(() => {
|
|
230
|
-
if (value) {
|
|
231
|
-
return value;
|
|
232
|
-
}
|
|
233
|
-
return placeholder || "Select Date";
|
|
234
|
-
}, [value, placeholder]);
|
|
235
|
-
const handleLayout = (e) => {
|
|
236
|
-
setHeight(e?.nativeEvent?.layout?.height || 180);
|
|
237
|
-
};
|
|
238
|
-
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(
|
|
239
|
-
import_react_native.TouchableOpacity,
|
|
240
|
-
{
|
|
241
|
-
style: [styles.input, errors && styles.inputError, inputStyle],
|
|
242
|
-
onPress: () => show(value)
|
|
243
|
-
},
|
|
244
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
245
|
-
import_react_native.Text,
|
|
246
|
-
{
|
|
247
|
-
style: [
|
|
248
|
-
styles.inputText,
|
|
249
|
-
!value && styles.inputTextPlaceholder,
|
|
250
|
-
inputTextStyle
|
|
251
|
-
]
|
|
252
|
-
},
|
|
253
|
-
dateValue
|
|
254
|
-
)
|
|
255
|
-
), errors && errors.length > 0 && /* @__PURE__ */ import_react.default.createElement(import_react_native.Text, { style: [styles.errorText, errorStyle] }, errors[0])), /* @__PURE__ */ import_react.default.createElement(
|
|
256
|
-
import_bottom_sheet.BottomSheetModal,
|
|
257
|
-
{
|
|
258
|
-
ref: bottomSheetRef,
|
|
259
|
-
snapPoints: ["50%"],
|
|
260
|
-
backgroundStyle: { backgroundColor: "#fff" },
|
|
261
|
-
enableDynamicSizing: false,
|
|
262
|
-
backdropComponent: (props) => /* @__PURE__ */ import_react.default.createElement(
|
|
263
|
-
import_bottom_sheet.BottomSheetBackdrop,
|
|
264
|
-
{
|
|
265
|
-
...props,
|
|
266
|
-
disappearsOnIndex: -1,
|
|
267
|
-
appearsOnIndex: 0
|
|
268
|
-
}
|
|
269
|
-
),
|
|
270
|
-
enableContentPanningGesture: false,
|
|
271
|
-
enableHandlePanningGesture: false,
|
|
272
|
-
enablePanDownToClose: false
|
|
273
|
-
},
|
|
274
|
-
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(
|
|
275
|
-
import_react_native_wheel_scrollview_picker.default,
|
|
276
|
-
{
|
|
277
|
-
dataSource: days,
|
|
278
|
-
selectedIndex: findSelectedDayByIndex,
|
|
279
|
-
renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
|
|
280
|
-
import_react_native.Text,
|
|
281
|
-
{
|
|
282
|
-
style: data === day ? styles.pickerItemBold : styles.pickerItem
|
|
283
|
-
},
|
|
284
|
-
data
|
|
285
|
-
),
|
|
286
|
-
onValueChange: (value2) => setDay(value2),
|
|
287
|
-
wrapperHeight: height,
|
|
288
|
-
itemHeight: 40,
|
|
289
|
-
highlightBorderWidth: 0.5,
|
|
290
|
-
highlightColor,
|
|
291
|
-
wrapperBackground: "#FFFFFF"
|
|
292
|
-
}
|
|
293
|
-
), /* @__PURE__ */ import_react.default.createElement(
|
|
294
|
-
import_react_native_wheel_scrollview_picker.default,
|
|
295
|
-
{
|
|
296
|
-
dataSource: displayMonths,
|
|
297
|
-
selectedIndex: findSelectedMonthByIndex,
|
|
298
|
-
renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
|
|
299
|
-
import_react_native.Text,
|
|
300
|
-
{
|
|
301
|
-
style: data === (showTimePicker ? month.slice(0, 3) : month) ? styles.pickerItemBold : styles.pickerItem
|
|
302
|
-
},
|
|
303
|
-
data
|
|
304
|
-
),
|
|
305
|
-
onValueChange: (value2) => handleMonthChange(value2),
|
|
306
|
-
wrapperHeight: height,
|
|
307
|
-
itemHeight: 40,
|
|
308
|
-
highlightBorderWidth: 0.5,
|
|
309
|
-
highlightColor,
|
|
310
|
-
wrapperBackground: "#FFFFFF"
|
|
311
|
-
}
|
|
312
|
-
), /* @__PURE__ */ import_react.default.createElement(
|
|
313
|
-
import_react_native_wheel_scrollview_picker.default,
|
|
314
|
-
{
|
|
315
|
-
dataSource: years,
|
|
316
|
-
selectedIndex: findSelectedYearByIndex,
|
|
317
|
-
renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
|
|
318
|
-
import_react_native.Text,
|
|
319
|
-
{
|
|
320
|
-
style: data === year ? styles.pickerItemBold : styles.pickerItem
|
|
321
|
-
},
|
|
322
|
-
data
|
|
323
|
-
),
|
|
324
|
-
onValueChange: (value2) => handleYearChange(value2),
|
|
325
|
-
wrapperHeight: height,
|
|
326
|
-
itemHeight: 40,
|
|
327
|
-
highlightBorderWidth: 0.5,
|
|
328
|
-
highlightColor,
|
|
329
|
-
wrapperBackground: "#FFFFFF"
|
|
330
|
-
}
|
|
331
|
-
), showTimePicker && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
332
|
-
import_react_native_wheel_scrollview_picker.default,
|
|
333
|
-
{
|
|
334
|
-
dataSource: hours,
|
|
335
|
-
selectedIndex: hours.findIndex((val) => val === hour),
|
|
336
|
-
renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
|
|
337
|
-
import_react_native.Text,
|
|
338
|
-
{
|
|
339
|
-
style: data === hour ? styles.pickerItemBold : styles.pickerItem
|
|
340
|
-
},
|
|
341
|
-
data
|
|
342
|
-
),
|
|
343
|
-
onValueChange: (value2) => setHour(value2),
|
|
344
|
-
wrapperHeight: height,
|
|
345
|
-
itemHeight: 40,
|
|
346
|
-
highlightBorderWidth: 0.5,
|
|
347
|
-
highlightColor,
|
|
348
|
-
wrapperBackground: "#FFFFFF"
|
|
349
|
-
}
|
|
350
|
-
), /* @__PURE__ */ import_react.default.createElement(
|
|
351
|
-
import_react_native_wheel_scrollview_picker.default,
|
|
352
|
-
{
|
|
353
|
-
dataSource: minutes,
|
|
354
|
-
selectedIndex: minutes.findIndex((val) => val === minute),
|
|
355
|
-
renderItem: (data) => /* @__PURE__ */ import_react.default.createElement(
|
|
356
|
-
import_react_native.Text,
|
|
357
|
-
{
|
|
358
|
-
style: data === minute ? styles.pickerItemBold : styles.pickerItem
|
|
359
|
-
},
|
|
360
|
-
data
|
|
361
|
-
),
|
|
362
|
-
onValueChange: (value2) => setMinute(value2),
|
|
363
|
-
wrapperHeight: height,
|
|
364
|
-
itemHeight: 40,
|
|
365
|
-
highlightBorderWidth: 0.5,
|
|
366
|
-
highlightColor,
|
|
367
|
-
wrapperBackground: "#FFFFFF"
|
|
368
|
-
}
|
|
369
|
-
))), /* @__PURE__ */ import_react.default.createElement(
|
|
370
|
-
import_react_native.View,
|
|
371
|
-
{
|
|
372
|
-
style: [
|
|
373
|
-
styles.buttonContainer,
|
|
374
|
-
{
|
|
375
|
-
paddingBottom: import_react_native.Platform.OS === "ios" ? 20 : 20
|
|
376
|
-
}
|
|
377
|
-
]
|
|
378
|
-
},
|
|
379
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
380
|
-
InternalButton,
|
|
381
|
-
{
|
|
382
|
-
onPress: () => bottomSheetRef.current?.close(),
|
|
383
|
-
outline: true,
|
|
384
|
-
style: cancelButtonStyle,
|
|
385
|
-
textStyle: cancelButtonTextStyle
|
|
386
|
-
},
|
|
387
|
-
"Cancel"
|
|
388
|
-
),
|
|
389
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
390
|
-
InternalButton,
|
|
391
|
-
{
|
|
392
|
-
onPress: handleSetDate,
|
|
393
|
-
style: buttonStyle,
|
|
394
|
-
textStyle: buttonTextStyle
|
|
395
|
-
},
|
|
396
|
-
"Save"
|
|
397
|
-
)
|
|
398
|
-
))
|
|
399
|
-
));
|
|
400
|
-
}
|
|
401
|
-
);
|
|
402
|
-
var styles = import_react_native.StyleSheet.create({
|
|
403
|
-
container: {
|
|
404
|
-
flexDirection: "column",
|
|
405
|
-
gap: 8
|
|
406
|
-
},
|
|
407
|
-
label: {
|
|
408
|
-
fontSize: 14,
|
|
409
|
-
color: "#6B7280"
|
|
410
|
-
},
|
|
411
|
-
subText: {
|
|
412
|
-
fontSize: 14,
|
|
413
|
-
color: "#6B7280",
|
|
414
|
-
width: "95%"
|
|
415
|
-
},
|
|
416
|
-
input: {
|
|
417
|
-
fontSize: 16,
|
|
418
|
-
color: "#000",
|
|
419
|
-
backgroundColor: "#F3F4F6",
|
|
420
|
-
borderRadius: 16,
|
|
421
|
-
padding: 14,
|
|
422
|
-
shadowColor: "#000",
|
|
423
|
-
shadowOffset: {
|
|
424
|
-
width: 0,
|
|
425
|
-
height: 2
|
|
426
|
-
},
|
|
427
|
-
shadowOpacity: 0.1,
|
|
428
|
-
shadowRadius: 3,
|
|
429
|
-
elevation: 2
|
|
430
|
-
},
|
|
431
|
-
inputError: {
|
|
432
|
-
borderWidth: 1,
|
|
433
|
-
borderColor: "#EF4444"
|
|
434
|
-
},
|
|
435
|
-
inputText: {
|
|
436
|
-
fontSize: 16,
|
|
437
|
-
color: "#1F2937"
|
|
438
|
-
},
|
|
439
|
-
inputTextPlaceholder: {
|
|
440
|
-
color: "#9CA3AF"
|
|
441
|
-
},
|
|
442
|
-
errorText: {
|
|
443
|
-
fontSize: 12,
|
|
444
|
-
color: "#EF4444",
|
|
445
|
-
fontWeight: "bold"
|
|
446
|
-
},
|
|
447
|
-
modalContent: {
|
|
448
|
-
flexDirection: "column",
|
|
449
|
-
gap: 12,
|
|
450
|
-
marginHorizontal: 24,
|
|
451
|
-
flex: 1
|
|
452
|
-
},
|
|
453
|
-
modalTitle: {
|
|
454
|
-
fontSize: 20,
|
|
455
|
-
fontWeight: "bold",
|
|
456
|
-
color: "#1F2937"
|
|
457
|
-
},
|
|
458
|
-
pickerContainer: {
|
|
459
|
-
flexDirection: "row",
|
|
460
|
-
justifyContent: "space-between",
|
|
461
|
-
paddingVertical: 16,
|
|
462
|
-
flex: 1
|
|
463
|
-
},
|
|
464
|
-
pickerItem: {
|
|
465
|
-
fontSize: 16,
|
|
466
|
-
color: "#1F2937"
|
|
467
|
-
},
|
|
468
|
-
pickerItemBold: {
|
|
469
|
-
fontSize: 16,
|
|
470
|
-
color: "#1F2937",
|
|
471
|
-
fontWeight: "bold"
|
|
472
|
-
},
|
|
473
|
-
buttonContainer: {
|
|
474
|
-
flexDirection: "row",
|
|
475
|
-
justifyContent: "space-between",
|
|
476
|
-
gap: 24,
|
|
477
|
-
paddingVertical: 16,
|
|
478
|
-
backgroundColor: "#fff"
|
|
479
|
-
},
|
|
480
|
-
button: {
|
|
481
|
-
flex: 1,
|
|
482
|
-
backgroundColor: "#3B82F6",
|
|
483
|
-
borderRadius: 12,
|
|
484
|
-
paddingVertical: 14,
|
|
485
|
-
paddingHorizontal: 20,
|
|
486
|
-
alignItems: "center",
|
|
487
|
-
justifyContent: "center"
|
|
488
|
-
},
|
|
489
|
-
buttonOutline: {
|
|
490
|
-
backgroundColor: "transparent",
|
|
491
|
-
borderWidth: 1,
|
|
492
|
-
borderColor: "#3B82F6"
|
|
493
|
-
},
|
|
494
|
-
buttonText: {
|
|
495
|
-
color: "#fff",
|
|
496
|
-
fontSize: 16,
|
|
497
|
-
fontWeight: "600"
|
|
498
|
-
},
|
|
499
|
-
buttonTextOutline: {
|
|
500
|
-
color: "#3B82F6"
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
var DatePicker_default = DatePicker;
|
|
504
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
505
|
-
0 && (module.exports = {
|
|
506
|
-
DatePicker
|
|
507
|
-
});
|
|
508
|
-
//# 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,493 +1 @@
|
|
|
1
|
-
|
|
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
|
-
var InternalButton = ({ onPress, children, outline, style, textStyle }) => {
|
|
30
|
-
return /* @__PURE__ */ React.createElement(
|
|
31
|
-
TouchableOpacity,
|
|
32
|
-
{
|
|
33
|
-
onPress,
|
|
34
|
-
style: [styles.button, outline && styles.buttonOutline, style]
|
|
35
|
-
},
|
|
36
|
-
/* @__PURE__ */ React.createElement(
|
|
37
|
-
Text,
|
|
38
|
-
{
|
|
39
|
-
style: [
|
|
40
|
-
styles.buttonText,
|
|
41
|
-
outline && styles.buttonTextOutline,
|
|
42
|
-
textStyle
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
children
|
|
46
|
-
)
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
var DatePicker = forwardRef(
|
|
50
|
-
({
|
|
51
|
-
value,
|
|
52
|
-
label,
|
|
53
|
-
placeholder,
|
|
54
|
-
onChange,
|
|
55
|
-
minDate,
|
|
56
|
-
maxDate,
|
|
57
|
-
showTimePicker = false,
|
|
58
|
-
dateFormat,
|
|
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 defaultFormat = useMemo(() => {
|
|
75
|
-
if (dateFormat) return dateFormat;
|
|
76
|
-
return showTimePicker ? "dd MMM yyyy HH:mm" : "dd MMMM yyyy";
|
|
77
|
-
}, [dateFormat, showTimePicker]);
|
|
78
|
-
const fullMonths = useMemo(
|
|
79
|
-
() => [
|
|
80
|
-
"January",
|
|
81
|
-
"February",
|
|
82
|
-
"March",
|
|
83
|
-
"April",
|
|
84
|
-
"May",
|
|
85
|
-
"June",
|
|
86
|
-
"July",
|
|
87
|
-
"August",
|
|
88
|
-
"September",
|
|
89
|
-
"October",
|
|
90
|
-
"November",
|
|
91
|
-
"December"
|
|
92
|
-
],
|
|
93
|
-
[]
|
|
94
|
-
);
|
|
95
|
-
const shortMonths = useMemo(
|
|
96
|
-
() => [
|
|
97
|
-
"Jan",
|
|
98
|
-
"Feb",
|
|
99
|
-
"Mar",
|
|
100
|
-
"Apr",
|
|
101
|
-
"May",
|
|
102
|
-
"Jun",
|
|
103
|
-
"Jul",
|
|
104
|
-
"Aug",
|
|
105
|
-
"Sep",
|
|
106
|
-
"Oct",
|
|
107
|
-
"Nov",
|
|
108
|
-
"Dec"
|
|
109
|
-
],
|
|
110
|
-
[]
|
|
111
|
-
);
|
|
112
|
-
const [day, setDay] = useState("01");
|
|
113
|
-
const [month, setMonth] = useState("January");
|
|
114
|
-
const [year, setYear] = useState(nowYear);
|
|
115
|
-
const [days, setDays] = useState([]);
|
|
116
|
-
const [years, setYears] = useState([]);
|
|
117
|
-
const [initComplete, setInitComplete] = useState(false);
|
|
118
|
-
const [hour, setHour] = useState("00");
|
|
119
|
-
const [minute, setMinute] = useState("00");
|
|
120
|
-
const [height, setHeight] = useState(180);
|
|
121
|
-
const displayMonths = showTimePicker ? shortMonths : fullMonths;
|
|
122
|
-
const show = useCallback(
|
|
123
|
-
(initialDate) => {
|
|
124
|
-
let selectedDate;
|
|
125
|
-
if (initialDate) {
|
|
126
|
-
try {
|
|
127
|
-
selectedDate = parse(initialDate, defaultFormat, /* @__PURE__ */ new Date());
|
|
128
|
-
if (!selectedDate || isNaN(selectedDate.getTime())) {
|
|
129
|
-
selectedDate = /* @__PURE__ */ new Date();
|
|
130
|
-
}
|
|
131
|
-
} catch {
|
|
132
|
-
selectedDate = /* @__PURE__ */ new Date();
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
selectedDate = /* @__PURE__ */ new Date();
|
|
136
|
-
}
|
|
137
|
-
const selectedDay = format(selectedDate, "dd");
|
|
138
|
-
const currentMonthIndex = selectedDate.getMonth();
|
|
139
|
-
const selectedMonth = fullMonths[currentMonthIndex];
|
|
140
|
-
const selectedYear = getYear(selectedDate);
|
|
141
|
-
const min = minDate ? parse(minDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : subYears(/* @__PURE__ */ new Date(), 200);
|
|
142
|
-
const max = maxDate ? parse(maxDate, "yyyy-MM-dd", /* @__PURE__ */ new Date()) : /* @__PURE__ */ new Date();
|
|
143
|
-
const allYears = Array.from(
|
|
144
|
-
{ length: 200 },
|
|
145
|
-
(_, i) => nowYear - i
|
|
146
|
-
).filter((y) => y >= getYear(min) && y <= getYear(max));
|
|
147
|
-
const totalDays = getDaysInMonth(
|
|
148
|
-
new Date(selectedYear, currentMonthIndex)
|
|
149
|
-
);
|
|
150
|
-
const daysArray = Array.from(
|
|
151
|
-
{ length: totalDays },
|
|
152
|
-
(_, i) => `${i + 1}`.padStart(2, "0")
|
|
153
|
-
);
|
|
154
|
-
setDay(selectedDay);
|
|
155
|
-
setMonth(selectedMonth);
|
|
156
|
-
setYear(selectedYear);
|
|
157
|
-
setYears(allYears);
|
|
158
|
-
setDays(daysArray);
|
|
159
|
-
setHour(format(selectedDate, "HH"));
|
|
160
|
-
setMinute(format(selectedDate, "mm"));
|
|
161
|
-
setInitComplete(true);
|
|
162
|
-
setTimeout(() => bottomSheetRef.current?.present(), 10);
|
|
163
|
-
},
|
|
164
|
-
[minDate, maxDate, fullMonths, showTimePicker, defaultFormat]
|
|
165
|
-
);
|
|
166
|
-
useImperativeHandle(ref, () => ({ show }), [show]);
|
|
167
|
-
const handleSetDate = () => {
|
|
168
|
-
const monthIndex = fullMonths.findIndex((m) => m === month);
|
|
169
|
-
const finalDateStr = `${year}-${(monthIndex + 1).toString().padStart(2, "0")}-${day}`;
|
|
170
|
-
const finalDate = showTimePicker ? parse(
|
|
171
|
-
`${finalDateStr} ${hour}:${minute}`,
|
|
172
|
-
"yyyy-MM-dd HH:mm",
|
|
173
|
-
/* @__PURE__ */ new Date()
|
|
174
|
-
) : parse(finalDateStr, "yyyy-MM-dd", /* @__PURE__ */ new Date());
|
|
175
|
-
const minDateTime = minDate ? startOfDay(parse(minDate, "yyyy-MM-dd", /* @__PURE__ */ new Date())) : null;
|
|
176
|
-
const maxDateTime = maxDate ? startOfDay(parse(maxDate, "yyyy-MM-dd", /* @__PURE__ */ new Date())) : null;
|
|
177
|
-
if (minDateTime && isBefore(startOfDay(finalDate), minDateTime) || maxDateTime && isAfter(startOfDay(finalDate), maxDateTime)) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
const formattedDate = format(finalDate, defaultFormat);
|
|
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 = 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 = 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 = 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__ */ 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(
|
|
225
|
-
TouchableOpacity,
|
|
226
|
-
{
|
|
227
|
-
style: [styles.input, errors && styles.inputError, inputStyle],
|
|
228
|
-
onPress: () => show(value)
|
|
229
|
-
},
|
|
230
|
-
/* @__PURE__ */ React.createElement(
|
|
231
|
-
Text,
|
|
232
|
-
{
|
|
233
|
-
style: [
|
|
234
|
-
styles.inputText,
|
|
235
|
-
!value && styles.inputTextPlaceholder,
|
|
236
|
-
inputTextStyle
|
|
237
|
-
]
|
|
238
|
-
},
|
|
239
|
-
dateValue
|
|
240
|
-
)
|
|
241
|
-
), errors && errors.length > 0 && /* @__PURE__ */ React.createElement(Text, { style: [styles.errorText, errorStyle] }, errors[0])), /* @__PURE__ */ React.createElement(
|
|
242
|
-
BottomSheetModal,
|
|
243
|
-
{
|
|
244
|
-
ref: bottomSheetRef,
|
|
245
|
-
snapPoints: ["50%"],
|
|
246
|
-
backgroundStyle: { backgroundColor: "#fff" },
|
|
247
|
-
enableDynamicSizing: false,
|
|
248
|
-
backdropComponent: (props) => /* @__PURE__ */ React.createElement(
|
|
249
|
-
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__ */ 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(
|
|
261
|
-
ScrollPicker,
|
|
262
|
-
{
|
|
263
|
-
dataSource: days,
|
|
264
|
-
selectedIndex: findSelectedDayByIndex,
|
|
265
|
-
renderItem: (data) => /* @__PURE__ */ React.createElement(
|
|
266
|
-
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__ */ React.createElement(
|
|
280
|
-
ScrollPicker,
|
|
281
|
-
{
|
|
282
|
-
dataSource: displayMonths,
|
|
283
|
-
selectedIndex: findSelectedMonthByIndex,
|
|
284
|
-
renderItem: (data) => /* @__PURE__ */ React.createElement(
|
|
285
|
-
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__ */ React.createElement(
|
|
299
|
-
ScrollPicker,
|
|
300
|
-
{
|
|
301
|
-
dataSource: years,
|
|
302
|
-
selectedIndex: findSelectedYearByIndex,
|
|
303
|
-
renderItem: (data) => /* @__PURE__ */ React.createElement(
|
|
304
|
-
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__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
318
|
-
ScrollPicker,
|
|
319
|
-
{
|
|
320
|
-
dataSource: hours,
|
|
321
|
-
selectedIndex: hours.findIndex((val) => val === hour),
|
|
322
|
-
renderItem: (data) => /* @__PURE__ */ React.createElement(
|
|
323
|
-
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__ */ React.createElement(
|
|
337
|
-
ScrollPicker,
|
|
338
|
-
{
|
|
339
|
-
dataSource: minutes,
|
|
340
|
-
selectedIndex: minutes.findIndex((val) => val === minute),
|
|
341
|
-
renderItem: (data) => /* @__PURE__ */ React.createElement(
|
|
342
|
-
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__ */ React.createElement(
|
|
356
|
-
View,
|
|
357
|
-
{
|
|
358
|
-
style: [
|
|
359
|
-
styles.buttonContainer,
|
|
360
|
-
{
|
|
361
|
-
paddingBottom: Platform.OS === "ios" ? 20 : 20
|
|
362
|
-
}
|
|
363
|
-
]
|
|
364
|
-
},
|
|
365
|
-
/* @__PURE__ */ React.createElement(
|
|
366
|
-
InternalButton,
|
|
367
|
-
{
|
|
368
|
-
onPress: () => bottomSheetRef.current?.close(),
|
|
369
|
-
outline: true,
|
|
370
|
-
style: cancelButtonStyle,
|
|
371
|
-
textStyle: cancelButtonTextStyle
|
|
372
|
-
},
|
|
373
|
-
"Cancel"
|
|
374
|
-
),
|
|
375
|
-
/* @__PURE__ */ React.createElement(
|
|
376
|
-
InternalButton,
|
|
377
|
-
{
|
|
378
|
-
onPress: handleSetDate,
|
|
379
|
-
style: buttonStyle,
|
|
380
|
-
textStyle: buttonTextStyle
|
|
381
|
-
},
|
|
382
|
-
"Save"
|
|
383
|
-
)
|
|
384
|
-
))
|
|
385
|
-
));
|
|
386
|
-
}
|
|
387
|
-
);
|
|
388
|
-
var styles = 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
|
-
export {
|
|
491
|
-
DatePicker_default as DatePicker
|
|
492
|
-
};
|
|
493
|
-
//# 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.
|
|
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",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"react-native-safe-area-context": ">=4.0.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"classnames": "^2.5.1",
|
|
49
48
|
"date-fns": "^3.3.1",
|
|
50
49
|
"react-native-wheel-scrollview-picker": "^2.0.1"
|
|
51
50
|
},
|
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\";\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 dateFormat?: string; // Custom format (e.g., \"yyyy-MM-dd\", \"dd/MM/yyyy\", \"MMM dd, yyyy\")\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 dateFormat,\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\n // Default formats if not provided\n const defaultFormat = useMemo(() => {\n if (dateFormat) return dateFormat;\n return showTimePicker ? \"dd MMM yyyy HH:mm\" : \"dd MMMM yyyy\";\n }, [dateFormat, showTimePicker]);\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 let selectedDate: Date;\n if (initialDate) {\n try {\n selectedDate = parse(initialDate, defaultFormat, new Date());\n // If parsing fails or returns invalid date, use current date\n if (!selectedDate || isNaN(selectedDate.getTime())) {\n selectedDate = new Date();\n }\n } catch {\n selectedDate = new Date();\n }\n } else {\n selectedDate = new Date();\n }\n\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, showTimePicker, defaultFormat]\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 // Format the date according to custom format or default\n const formattedDate = format(finalDate, defaultFormat);\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\" ? 20 : 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;AA8BtD,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;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GACA,QACG;AACH,UAAM,WAAU,oBAAI,KAAK,GAAE,YAAY;AACvC,UA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;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"]}
|
package/dist/index.mjs.map
DELETED
|
@@ -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\";\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 dateFormat?: string; // Custom format (e.g., \"yyyy-MM-dd\", \"dd/MM/yyyy\", \"MMM dd, yyyy\")\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 dateFormat,\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\n // Default formats if not provided\n const defaultFormat = useMemo(() => {\n if (dateFormat) return dateFormat;\n return showTimePicker ? \"dd MMM yyyy HH:mm\" : \"dd MMMM yyyy\";\n }, [dateFormat, showTimePicker]);\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 let selectedDate: Date;\n if (initialDate) {\n try {\n selectedDate = parse(initialDate, defaultFormat, new Date());\n // If parsing fails or returns invalid date, use current date\n if (!selectedDate || isNaN(selectedDate.getTime())) {\n selectedDate = new Date();\n }\n } catch {\n selectedDate = new Date();\n }\n } else {\n selectedDate = new Date();\n }\n\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, showTimePicker, defaultFormat]\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 // Format the date according to custom format or default\n const formattedDate = format(finalDate, defaultFormat);\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\" ? 20 : 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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