react-native-smart-date-picker 0.1.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/README.md +163 -0
- package/lib/components/DateColumn.d.ts +3 -0
- package/lib/components/DateColumn.d.ts.map +1 -0
- package/lib/components/DateColumn.js +12 -0
- package/lib/components/HourColumn.d.ts +3 -0
- package/lib/components/HourColumn.d.ts.map +1 -0
- package/lib/components/HourColumn.js +12 -0
- package/lib/components/MinuteColumn.d.ts +3 -0
- package/lib/components/MinuteColumn.d.ts.map +1 -0
- package/lib/components/MinuteColumn.js +12 -0
- package/lib/components/MonthColumn.d.ts +3 -0
- package/lib/components/MonthColumn.d.ts.map +1 -0
- package/lib/components/MonthColumn.js +12 -0
- package/lib/components/PickerModal.d.ts +10 -0
- package/lib/components/PickerModal.d.ts.map +1 -0
- package/lib/components/PickerModal.js +27 -0
- package/lib/components/SelectionOverlay.d.ts +10 -0
- package/lib/components/SelectionOverlay.d.ts.map +1 -0
- package/lib/components/SelectionOverlay.js +26 -0
- package/lib/components/SmartDatePicker.d.ts +4 -0
- package/lib/components/SmartDatePicker.d.ts.map +1 -0
- package/lib/components/SmartDatePicker.js +154 -0
- package/lib/components/WheelColumn.d.ts +17 -0
- package/lib/components/WheelColumn.d.ts.map +1 -0
- package/lib/components/WheelColumn.js +126 -0
- package/lib/components/YearColumn.d.ts +3 -0
- package/lib/components/YearColumn.d.ts.map +1 -0
- package/lib/components/YearColumn.js +12 -0
- package/lib/hooks/useDatePicker.d.ts +13 -0
- package/lib/hooks/useDatePicker.d.ts.map +1 -0
- package/lib/hooks/useDatePicker.js +31 -0
- package/lib/hooks/useTheme.d.ts +13 -0
- package/lib/hooks/useTheme.d.ts.map +1 -0
- package/lib/hooks/useTheme.js +7 -0
- package/lib/hooks/useWheel.d.ts +5 -0
- package/lib/hooks/useWheel.d.ts.map +1 -0
- package/lib/hooks/useWheel.js +12 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +23 -0
- package/lib/types/index.d.ts +59 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +2 -0
- package/lib/utils/constants.d.ts +4 -0
- package/lib/utils/constants.d.ts.map +1 -0
- package/lib/utils/constants.js +19 -0
- package/lib/utils/dateUtils.d.ts +4 -0
- package/lib/utils/dateUtils.d.ts.map +1 -0
- package/lib/utils/dateUtils.js +21 -0
- package/lib/utils/generateData.d.ts +21 -0
- package/lib/utils/generateData.d.ts.map +1 -0
- package/lib/utils/generateData.js +95 -0
- package/lib/utils/validateDOB.d.ts +2 -0
- package/lib/utils/validateDOB.d.ts.map +1 -0
- package/lib/utils/validateDOB.js +17 -0
- package/package.json +54 -0
- package/src/components/DateColumn.tsx +14 -0
- package/src/components/HourColumn.tsx +14 -0
- package/src/components/MinuteColumn.tsx +14 -0
- package/src/components/MonthColumn.tsx +14 -0
- package/src/components/PickerModal.tsx +60 -0
- package/src/components/SelectionOverlay.tsx +45 -0
- package/src/components/SmartDatePicker.tsx +318 -0
- package/src/components/WheelColumn.tsx +231 -0
- package/src/components/YearColumn.tsx +14 -0
- package/src/hooks/useDatePicker.ts +47 -0
- package/src/hooks/useTheme.ts +18 -0
- package/src/hooks/useWheel.ts +13 -0
- package/src/index.ts +3 -0
- package/src/types/index.ts +77 -0
- package/src/utils/constants.ts +17 -0
- package/src/utils/dateUtils.ts +38 -0
- package/src/utils/generateData.ts +134 -0
- package/src/utils/validateDOB.ts +24 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YearColumn.d.ts","sourceRoot":"","sources":["../../src/components/YearColumn.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,CAAC,OAAO,UAAU,UAAU,CAC9B,KAAK,EAAE,GAAG,qBAQb"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = YearColumn;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const WheelColumn_1 = __importDefault(require("./WheelColumn"));
|
|
9
|
+
const generateData_1 = require("../utils/generateData");
|
|
10
|
+
function YearColumn(props) {
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(WheelColumn_1.default, Object.assign({ data: (0, generateData_1.generateYears)() }, props)));
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const useDatePicker: (date: Date) => {
|
|
2
|
+
day: number;
|
|
3
|
+
month: number;
|
|
4
|
+
year: number;
|
|
5
|
+
hour: number;
|
|
6
|
+
minute: number;
|
|
7
|
+
setDay: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
8
|
+
setMonth: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
9
|
+
setYear: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
10
|
+
setHour: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
11
|
+
setMinute: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useDatePicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDatePicker.d.ts","sourceRoot":"","sources":["../../src/hooks/useDatePicker.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,GACtB,MAAM,IAAI;;;;;;;;;;;CA2Cb,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDatePicker = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useDatePicker = (date) => {
|
|
6
|
+
const [day, setDay] = (0, react_1.useState)(date.getDate());
|
|
7
|
+
const [month, setMonth] = (0, react_1.useState)(date.getMonth() + 1);
|
|
8
|
+
const [year, setYear] = (0, react_1.useState)(date.getFullYear());
|
|
9
|
+
const [hour, setHour] = (0, react_1.useState)(date.getHours());
|
|
10
|
+
const [minute, setMinute] = (0, react_1.useState)(date.getMinutes());
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
setDay(date.getDate());
|
|
13
|
+
setMonth(date.getMonth() + 1);
|
|
14
|
+
setYear(date.getFullYear());
|
|
15
|
+
setHour(date.getHours());
|
|
16
|
+
setMinute(date.getMinutes());
|
|
17
|
+
}, [date]);
|
|
18
|
+
return {
|
|
19
|
+
day,
|
|
20
|
+
month,
|
|
21
|
+
year,
|
|
22
|
+
hour,
|
|
23
|
+
minute,
|
|
24
|
+
setDay,
|
|
25
|
+
setMonth,
|
|
26
|
+
setYear,
|
|
27
|
+
setHour,
|
|
28
|
+
setMinute,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
exports.useDatePicker = useDatePicker;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SmartDatePickerTheme } from "../types";
|
|
2
|
+
export declare const useTheme: (theme?: Partial<SmartDatePickerTheme>) => {
|
|
3
|
+
primaryColor: string;
|
|
4
|
+
backgroundColor: string;
|
|
5
|
+
textColor: string;
|
|
6
|
+
buttonTextColor: string;
|
|
7
|
+
overlayBorderColor: string;
|
|
8
|
+
disabledTextColor: string;
|
|
9
|
+
selectionOverlayColor: string;
|
|
10
|
+
headerBackgroundColor: string;
|
|
11
|
+
wheelBackgroundColor: string;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,eAAO,MAAM,QAAQ,GACjB,QAAQ,OAAO,CAAC,oBAAoB,CAAC;;;;;;;;;;CAcxC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTheme = void 0;
|
|
4
|
+
const useTheme = (theme) => {
|
|
5
|
+
return Object.assign({ primaryColor: "#4F46E5", backgroundColor: "#FFFFFF", textColor: "#111827", buttonTextColor: "#4F46E5", overlayBorderColor: "#D1D5DB", disabledTextColor: "#9CA3AF", selectionOverlayColor: "transparent", headerBackgroundColor: "#FFFFFF", wheelBackgroundColor: "#FFFFFF" }, theme);
|
|
6
|
+
};
|
|
7
|
+
exports.useTheme = useTheme;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWheel.d.ts","sourceRoot":"","sources":["../../src/hooks/useWheel.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,GACjB,cAAc,MAAM;;;CASvB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWheel = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useWheel = (initialValue) => {
|
|
6
|
+
const [selected, setSelected] = (0, react_1.useState)(initialValue);
|
|
7
|
+
return {
|
|
8
|
+
selected,
|
|
9
|
+
setSelected,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
exports.useWheel = useWheel;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE1E,cAAc,SAAS,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.SmartDatePicker = void 0;
|
|
21
|
+
var SmartDatePicker_1 = require("./components/SmartDatePicker");
|
|
22
|
+
Object.defineProperty(exports, "SmartDatePicker", { enumerable: true, get: function () { return __importDefault(SmartDatePicker_1).default; } });
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
export interface SmartDatePickerTheme {
|
|
3
|
+
primaryColor?: string;
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
textColor?: string;
|
|
6
|
+
buttonTextColor?: string;
|
|
7
|
+
overlayBorderColor?: string;
|
|
8
|
+
disabledTextColor?: string;
|
|
9
|
+
selectionOverlayColor?: string;
|
|
10
|
+
headerBackgroundColor?: string;
|
|
11
|
+
wheelBackgroundColor?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface SmartDatePickerProps {
|
|
14
|
+
visible: boolean;
|
|
15
|
+
value?: Date;
|
|
16
|
+
mode?: "date" | "time" | "datetime";
|
|
17
|
+
minimumDate?: Date;
|
|
18
|
+
maximumDate?: Date;
|
|
19
|
+
minYear?: number;
|
|
20
|
+
maxYear?: number;
|
|
21
|
+
is24Hour?: boolean;
|
|
22
|
+
minuteInterval?: number;
|
|
23
|
+
showSelectionOverlay?: boolean;
|
|
24
|
+
infiniteScroll?: boolean;
|
|
25
|
+
itemHeight?: number;
|
|
26
|
+
visibleRows?: number;
|
|
27
|
+
modalTitle?: string;
|
|
28
|
+
confirmText?: string;
|
|
29
|
+
cancelText?: string;
|
|
30
|
+
theme?: Partial<SmartDatePickerTheme> | "light" | "dark" | "auto";
|
|
31
|
+
primaryColor?: string;
|
|
32
|
+
backgroundColor?: string;
|
|
33
|
+
textColor?: string;
|
|
34
|
+
selectedTextColor?: string;
|
|
35
|
+
buttonTextColor?: string;
|
|
36
|
+
overlayBorderColor?: string;
|
|
37
|
+
disabledTextColor?: string;
|
|
38
|
+
selectionOverlayColor?: string;
|
|
39
|
+
headerBackgroundColor?: string;
|
|
40
|
+
wheelBackgroundColor?: string;
|
|
41
|
+
containerStyle?: ViewStyle;
|
|
42
|
+
wheelStyle?: ViewStyle;
|
|
43
|
+
overlayStyle?: ViewStyle;
|
|
44
|
+
textStyle?: TextStyle;
|
|
45
|
+
selectedTextStyle?: TextStyle;
|
|
46
|
+
customTheme?: SmartDatePickerTheme;
|
|
47
|
+
minDateTheme?: Partial<SmartDatePickerTheme>;
|
|
48
|
+
maxDateTheme?: Partial<SmartDatePickerTheme>;
|
|
49
|
+
onConfirm: (date: Date) => void;
|
|
50
|
+
onCancel: () => void;
|
|
51
|
+
onValueChange?: (date: Date) => void;
|
|
52
|
+
onOpen?: () => void;
|
|
53
|
+
onClose?: () => void;
|
|
54
|
+
}
|
|
55
|
+
export interface WheelItem {
|
|
56
|
+
label: string;
|
|
57
|
+
value: number | string;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=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O,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,eAAO,MAAM,MAAM,UAalB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MONTHS = exports.VISIBLE_ITEMS = exports.ITEM_HEIGHT = void 0;
|
|
4
|
+
exports.ITEM_HEIGHT = 44;
|
|
5
|
+
exports.VISIBLE_ITEMS = 5;
|
|
6
|
+
exports.MONTHS = [
|
|
7
|
+
"Jan",
|
|
8
|
+
"Feb",
|
|
9
|
+
"Mar",
|
|
10
|
+
"Apr",
|
|
11
|
+
"May",
|
|
12
|
+
"Jun",
|
|
13
|
+
"Jul",
|
|
14
|
+
"Aug",
|
|
15
|
+
"Sep",
|
|
16
|
+
"Oct",
|
|
17
|
+
"Nov",
|
|
18
|
+
"Dec",
|
|
19
|
+
];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const getDaysInMonth: (month: number, year: number) => number;
|
|
2
|
+
export declare const buildDate: (day: number, month: number, year: number, hour: number, minute: number) => Date;
|
|
3
|
+
export declare const clampDate: (date: Date, minimumDate?: Date, maximumDate?: Date) => Date;
|
|
4
|
+
//# sourceMappingURL=dateUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/utils/dateUtils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GACvB,OAAO,MAAM,EACb,MAAM,MAAM,WAGf,CAAC;AAEF,eAAO,MAAM,SAAS,GAClB,KAAK,MAAM,EACX,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,QAAQ,MAAM,SASjB,CAAC;AAEF,eAAO,MAAM,SAAS,GAClB,MAAM,IAAI,EACV,cAAc,IAAI,EAClB,cAAc,IAAI,SAWrB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clampDate = exports.buildDate = exports.getDaysInMonth = void 0;
|
|
4
|
+
const getDaysInMonth = (month, year) => {
|
|
5
|
+
return new Date(year, month, 0).getDate();
|
|
6
|
+
};
|
|
7
|
+
exports.getDaysInMonth = getDaysInMonth;
|
|
8
|
+
const buildDate = (day, month, year, hour, minute) => {
|
|
9
|
+
return new Date(year, month - 1, day, hour, minute);
|
|
10
|
+
};
|
|
11
|
+
exports.buildDate = buildDate;
|
|
12
|
+
const clampDate = (date, minimumDate, maximumDate) => {
|
|
13
|
+
if (minimumDate && date < minimumDate) {
|
|
14
|
+
return minimumDate;
|
|
15
|
+
}
|
|
16
|
+
if (maximumDate && date > maximumDate) {
|
|
17
|
+
return maximumDate;
|
|
18
|
+
}
|
|
19
|
+
return date;
|
|
20
|
+
};
|
|
21
|
+
exports.clampDate = clampDate;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const generateDays: (month?: number, year?: number) => {
|
|
2
|
+
label: string;
|
|
3
|
+
value: number;
|
|
4
|
+
}[];
|
|
5
|
+
export declare const generateMonths: () => {
|
|
6
|
+
label: string;
|
|
7
|
+
value: number;
|
|
8
|
+
}[];
|
|
9
|
+
export declare const generateYears: (start?: number, end?: number) => {
|
|
10
|
+
label: string;
|
|
11
|
+
value: number;
|
|
12
|
+
}[];
|
|
13
|
+
export declare const generateHours: (is24Hour?: boolean) => {
|
|
14
|
+
label: string;
|
|
15
|
+
value: number;
|
|
16
|
+
}[];
|
|
17
|
+
export declare const generateMinutes: (interval?: number) => {
|
|
18
|
+
label: string;
|
|
19
|
+
value: number;
|
|
20
|
+
}[];
|
|
21
|
+
//# sourceMappingURL=generateData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateData.d.ts","sourceRoot":"","sources":["../../src/utils/generateData.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,GACrB,QAAO,MAAU,EACjB,OAAM,MAAa;;;GAetB,CAAC;AAEF,eAAO,MAAM,cAAc;;;GAIpB,CAAC;AAER,eAAO,MAAM,aAAa,GACtB,QAAO,MAAa,EACpB,MAAK,MAAsC;;;GAQ1C,CAAC;AAEN,eAAO,MAAM,aAAa,GACtB,WAAU,OAAc;;;GAYvB,CAAC;AAEN,eAAO,MAAM,eAAe,GACxB,iBAAY;;;GAYX,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateMinutes = exports.generateHours = exports.generateYears = exports.generateMonths = exports.generateDays = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const generateDays = (month = 1, year = 1970) => {
|
|
6
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
7
|
+
return Array.from({ length: daysInMonth }, (_, i) => ({
|
|
8
|
+
label: String(i + 1),
|
|
9
|
+
value: i + 1,
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
exports.generateDays = generateDays;
|
|
13
|
+
const generateMonths = () => constants_1.MONTHS.map((month, index) => ({
|
|
14
|
+
label: month,
|
|
15
|
+
value: index + 1,
|
|
16
|
+
}));
|
|
17
|
+
exports.generateMonths = generateMonths;
|
|
18
|
+
const generateYears = (start = 1900, end = new Date().getFullYear() + 50) => Array.from({ length: end - start + 1 }, (_, i) => ({
|
|
19
|
+
label: String(start + i),
|
|
20
|
+
value: start + i,
|
|
21
|
+
}));
|
|
22
|
+
exports.generateYears = generateYears;
|
|
23
|
+
const generateHours = (is24Hour = true) => Array.from({
|
|
24
|
+
length: is24Hour ? 24 : 12,
|
|
25
|
+
}, (_, i) => ({
|
|
26
|
+
label: String(is24Hour ? i : i + 1).padStart(2, "0"),
|
|
27
|
+
value: is24Hour ? i : i + 1,
|
|
28
|
+
}));
|
|
29
|
+
exports.generateHours = generateHours;
|
|
30
|
+
const generateMinutes = (interval = 1) => Array.from({
|
|
31
|
+
length: 60 / interval,
|
|
32
|
+
}, (_, i) => ({
|
|
33
|
+
label: String(i * interval).padStart(2, "0"),
|
|
34
|
+
value: i * interval,
|
|
35
|
+
}));
|
|
36
|
+
exports.generateMinutes = generateMinutes;
|
|
37
|
+
// import { MONTHS } from "./constants";
|
|
38
|
+
// export const generateDays = (
|
|
39
|
+
// month?: number,
|
|
40
|
+
// year?: number
|
|
41
|
+
// ) => {
|
|
42
|
+
// let totalDays = 31;
|
|
43
|
+
// if (month && year) {
|
|
44
|
+
// totalDays = new Date(year, month, 0).getDate();
|
|
45
|
+
// }
|
|
46
|
+
// return Array.from(
|
|
47
|
+
// { length: totalDays },
|
|
48
|
+
// (_, i) => ({
|
|
49
|
+
// label: String(i + 1),
|
|
50
|
+
// value: i + 1,
|
|
51
|
+
// })
|
|
52
|
+
// );
|
|
53
|
+
// };
|
|
54
|
+
// export const generateMonths = () =>
|
|
55
|
+
// MONTHS.map((month, index) => ({
|
|
56
|
+
// label: month,
|
|
57
|
+
// value: index + 1,
|
|
58
|
+
// }));
|
|
59
|
+
// export const generateYears = (
|
|
60
|
+
// start = 1900,
|
|
61
|
+
// end = new Date().getFullYear() + 50
|
|
62
|
+
// ) =>
|
|
63
|
+
// Array.from(
|
|
64
|
+
// { length: end - start + 1 },
|
|
65
|
+
// (_, i) => ({
|
|
66
|
+
// label: String(start + i),
|
|
67
|
+
// value: start + i,
|
|
68
|
+
// })
|
|
69
|
+
// );
|
|
70
|
+
// export const generateHours = (
|
|
71
|
+
// is24Hour = true
|
|
72
|
+
// ) =>
|
|
73
|
+
// Array.from(
|
|
74
|
+
// {
|
|
75
|
+
// length: is24Hour ? 24 : 12,
|
|
76
|
+
// },
|
|
77
|
+
// (_, i) => ({
|
|
78
|
+
// label: String(
|
|
79
|
+
// is24Hour ? i : i + 1
|
|
80
|
+
// ).padStart(2, "0"),
|
|
81
|
+
// value: is24Hour ? i : i + 1,
|
|
82
|
+
// })
|
|
83
|
+
// );
|
|
84
|
+
// export const generateMinutes = (
|
|
85
|
+
// step = 1
|
|
86
|
+
// ) =>
|
|
87
|
+
// Array.from(
|
|
88
|
+
// { length: 60 / step },
|
|
89
|
+
// (_, i) => ({
|
|
90
|
+
// label: String(
|
|
91
|
+
// i * step
|
|
92
|
+
// ).padStart(2, "0"),
|
|
93
|
+
// value: i * step,
|
|
94
|
+
// })
|
|
95
|
+
// );
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateDOB.d.ts","sourceRoot":"","sources":["../../src/utils/validateDOB.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GACpB,MAAM,IAAI,EACV,eAAW,YAqBd,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateDOB = void 0;
|
|
4
|
+
const validateDOB = (date, minAge = 18) => {
|
|
5
|
+
const today = new Date();
|
|
6
|
+
let age = today.getFullYear() -
|
|
7
|
+
date.getFullYear();
|
|
8
|
+
const m = today.getMonth() -
|
|
9
|
+
date.getMonth();
|
|
10
|
+
if (m < 0 ||
|
|
11
|
+
(m === 0 &&
|
|
12
|
+
today.getDate() < date.getDate())) {
|
|
13
|
+
age--;
|
|
14
|
+
}
|
|
15
|
+
return age >= minAge;
|
|
16
|
+
};
|
|
17
|
+
exports.validateDOB = validateDOB;
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-smart-date-picker",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A lightweight, customizable React Native wheel-style date and datetime picker with identical UI on iOS and Android.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"source": "src/index.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"lib",
|
|
10
|
+
"src",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"react-native",
|
|
15
|
+
"date-picker",
|
|
16
|
+
"datetime-picker",
|
|
17
|
+
"wheel-picker",
|
|
18
|
+
"calendar",
|
|
19
|
+
"ios",
|
|
20
|
+
"android",
|
|
21
|
+
"typescript",
|
|
22
|
+
"react-native-date-picker",
|
|
23
|
+
"smart-date-picker"
|
|
24
|
+
],
|
|
25
|
+
"author": "Neeraj Singh",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"homepage": "https://github.com/neerajsingh/react-native-smart-date-picker",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/neerajsingh/react-native-smart-date-picker.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/neerajsingh/react-native-smart-date-picker/issues"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"watch": "tsc --watch",
|
|
38
|
+
"clean": "rm -rf lib",
|
|
39
|
+
"prepare": "npm run build",
|
|
40
|
+
"test": "echo \"No tests specified\""
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": ">=18.0.0",
|
|
44
|
+
"react-native": ">=0.72.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/react": "^19.2.17",
|
|
48
|
+
"@types/react-native": "^0.72.8",
|
|
49
|
+
"typescript": "^6.0.3"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=18"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import WheelColumn from "./WheelColumn";
|
|
3
|
+
import { generateDays } from "../utils/generateData";
|
|
4
|
+
|
|
5
|
+
export default function DateColumn(
|
|
6
|
+
props: any
|
|
7
|
+
) {
|
|
8
|
+
return (
|
|
9
|
+
<WheelColumn
|
|
10
|
+
data={generateDays()}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import WheelColumn from "./WheelColumn";
|
|
3
|
+
import { generateHours } from "../utils/generateData";
|
|
4
|
+
|
|
5
|
+
export default function HourColumn(
|
|
6
|
+
props: any
|
|
7
|
+
) {
|
|
8
|
+
return (
|
|
9
|
+
<WheelColumn
|
|
10
|
+
data={generateHours()}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import WheelColumn from "./WheelColumn";
|
|
3
|
+
import { generateMinutes } from "../utils/generateData";
|
|
4
|
+
|
|
5
|
+
export default function MinuteColumn(
|
|
6
|
+
props: any
|
|
7
|
+
) {
|
|
8
|
+
return (
|
|
9
|
+
<WheelColumn
|
|
10
|
+
data={generateMinutes()}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import WheelColumn from "./WheelColumn";
|
|
3
|
+
import { generateMonths } from "../utils/generateData";
|
|
4
|
+
|
|
5
|
+
export default function MonthColumn(
|
|
6
|
+
props: any
|
|
7
|
+
) {
|
|
8
|
+
return (
|
|
9
|
+
<WheelColumn
|
|
10
|
+
data={generateMonths()}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
Modal,
|
|
4
|
+
View,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
|
|
9
|
+
export default function PickerModal({
|
|
10
|
+
visible,
|
|
11
|
+
children,
|
|
12
|
+
backgroundColor,
|
|
13
|
+
containerStyle,
|
|
14
|
+
overlayStyle,
|
|
15
|
+
}: {
|
|
16
|
+
visible: boolean;
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
backgroundColor?: string;
|
|
19
|
+
containerStyle?: ViewStyle;
|
|
20
|
+
overlayStyle?: ViewStyle;
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<Modal
|
|
24
|
+
transparent
|
|
25
|
+
visible={visible}
|
|
26
|
+
animationType="slide"
|
|
27
|
+
>
|
|
28
|
+
<View style={[styles.container, containerStyle]}>
|
|
29
|
+
<View
|
|
30
|
+
style={[
|
|
31
|
+
styles.content,
|
|
32
|
+
overlayStyle,
|
|
33
|
+
{
|
|
34
|
+
backgroundColor:
|
|
35
|
+
backgroundColor || "#fff",
|
|
36
|
+
},
|
|
37
|
+
]}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</View>
|
|
41
|
+
</View>
|
|
42
|
+
</Modal>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
container: {
|
|
48
|
+
flex: 1,
|
|
49
|
+
justifyContent: "flex-end",
|
|
50
|
+
backgroundColor:
|
|
51
|
+
"rgba(0,0,0,0.4)",
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
content: {
|
|
55
|
+
height: 320,
|
|
56
|
+
backgroundColor: "#fff",
|
|
57
|
+
borderTopLeftRadius: 20,
|
|
58
|
+
borderTopRightRadius: 20,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
} from "react-native";
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
itemHeight?: number;
|
|
9
|
+
borderColor?: string;
|
|
10
|
+
selectionOverlayColor?: string;
|
|
11
|
+
overlayStyle?: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function SelectionOverlay({
|
|
15
|
+
itemHeight = 44,
|
|
16
|
+
borderColor = "#D1D5DB",
|
|
17
|
+
selectionOverlayColor = "transparent",
|
|
18
|
+
overlayStyle,
|
|
19
|
+
}: Props) {
|
|
20
|
+
return (
|
|
21
|
+
<View
|
|
22
|
+
pointerEvents="none"
|
|
23
|
+
style={[
|
|
24
|
+
styles.overlay,
|
|
25
|
+
overlayStyle,
|
|
26
|
+
{
|
|
27
|
+
top: itemHeight * 2,
|
|
28
|
+
height: itemHeight,
|
|
29
|
+
borderColor,
|
|
30
|
+
backgroundColor: selectionOverlayColor,
|
|
31
|
+
},
|
|
32
|
+
]}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const styles = StyleSheet.create({
|
|
38
|
+
overlay: {
|
|
39
|
+
position: "absolute",
|
|
40
|
+
left: 0,
|
|
41
|
+
right: 0,
|
|
42
|
+
borderTopWidth: 1,
|
|
43
|
+
borderBottomWidth: 1,
|
|
44
|
+
},
|
|
45
|
+
});
|