expo-2k-datetime-picker 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +267 -0
- package/android/build.gradle +18 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/calendar2k/Calendar2kModule.kt +15 -0
- package/android/src/main/java/expo/modules/calendar2k/Calendar2kView.kt +26 -0
- package/build/Calendar2k.types.d.ts +38 -0
- package/build/Calendar2k.types.js +2 -0
- package/build/Calendar2kModule.d.ts +8 -0
- package/build/Calendar2kModule.js +10 -0
- package/build/Calendar2kModule.web.d.ts +6 -0
- package/build/Calendar2kModule.web.js +26 -0
- package/build/Calendar2kView.d.ts +4 -0
- package/build/Calendar2kView.js +366 -0
- package/build/Calendar2kView.web.d.ts +3 -0
- package/build/Calendar2kView.web.js +49 -0
- package/build/assets/assets/images/calendar.png +0 -0
- package/build/assets/assets/images/chevron-left.png +0 -0
- package/build/assets/assets/images/chevron-right.png +0 -0
- package/build/assets/assets/images/clock.png +0 -0
- package/build/assets/assets/images/swipe.png +0 -0
- package/build/assets/images/calendar.png +0 -0
- package/build/assets/images/chevron-left.png +0 -0
- package/build/assets/images/chevron-right.png +0 -0
- package/build/assets/images/clock.png +0 -0
- package/build/assets/images/swipe.png +0 -0
- package/build/components/ArrowButton.d.ts +8 -0
- package/build/components/ArrowButton.js +19 -0
- package/build/components/Backdrop.d.ts +5 -0
- package/build/components/Backdrop.js +25 -0
- package/build/components/DayLabel.d.ts +6 -0
- package/build/components/DayLabel.js +16 -0
- package/build/components/Icon.d.ts +6 -0
- package/build/components/Icon.js +16 -0
- package/build/components/SwipeIcon.d.ts +5 -0
- package/build/components/SwipeIcon.js +8 -0
- package/build/components/Time.d.ts +11 -0
- package/build/components/Time.js +95 -0
- package/build/components/TimeView.d.ts +10 -0
- package/build/components/TimeView.js +25 -0
- package/build/hooks/useCalendarDisclose.d.ts +4 -0
- package/build/hooks/useCalendarDisclose.js +9 -0
- package/build/libs/format.d.ts +4 -0
- package/build/libs/format.js +52 -0
- package/build/libs/formatNb.d.ts +1 -0
- package/build/libs/formatNb.js +6 -0
- package/build/libs/getDayMatrix.d.ts +1 -0
- package/build/libs/getDayMatrix.js +74 -0
- package/build/libs/getStatus.d.ts +14 -0
- package/build/libs/getStatus.js +37 -0
- package/build/libs/getStyle.d.ts +14 -0
- package/build/libs/getStyle.js +35 -0
- package/build/libs/isActive.d.ts +8 -0
- package/build/libs/isActive.js +17 -0
- package/build/libs/isToday.d.ts +1 -0
- package/build/libs/isToday.js +9 -0
- package/build/libs/resetTime.d.ts +1 -0
- package/build/libs/resetTime.js +6 -0
- package/build/libs/toHexColor.d.ts +1 -0
- package/build/libs/toHexColor.js +13 -0
- package/build/ui/index.d.ts +15 -0
- package/build/ui/index.js +35 -0
- package/expo-module.config.json +9 -0
- package/ios/Calendar2k.podspec +23 -0
- package/ios/Calendar2kModule.swift +12 -0
- package/ios/Calendar2kView.swift +18 -0
- package/package.json +53 -0
- package/src/Calendar2k.types.ts +40 -0
- package/src/Calendar2kModule.ts +9 -0
- package/src/Calendar2kModule.web.ts +7 -0
- package/src/Calendar2kView.tsx +416 -0
- package/src/Calendar2kView.web.tsx +19 -0
- package/src/assets/images/calendar.png +0 -0
- package/src/assets/images/chevron-left.png +0 -0
- package/src/assets/images/chevron-right.png +0 -0
- package/src/assets/images/clock.png +0 -0
- package/src/assets/images/swipe.png +0 -0
- package/src/components/ArrowButton.tsx +40 -0
- package/src/components/Backdrop.tsx +31 -0
- package/src/components/DayLabel.tsx +20 -0
- package/src/components/Icon.tsx +24 -0
- package/src/components/SwipeIcon.tsx +13 -0
- package/src/components/Time.tsx +93 -0
- package/src/components/TimeView.tsx +64 -0
- package/src/hooks/useCalendarDisclose.ts +9 -0
- package/src/libs/format.ts +57 -0
- package/src/libs/formatNb.ts +3 -0
- package/src/libs/getDayMatrix.ts +73 -0
- package/src/libs/getStatus.ts +47 -0
- package/src/libs/getStyle.ts +53 -0
- package/src/libs/isActive.ts +20 -0
- package/src/libs/isToday.ts +9 -0
- package/src/libs/resetTime.ts +3 -0
- package/src/libs/toHexColor.ts +13 -0
- package/src/ui/index.tsx +51 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,95 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = Time;
|
|
40
|
+
var react_1 = __importStar(require("react"));
|
|
41
|
+
var react_native_1 = require("react-native");
|
|
42
|
+
var formatNb_1 = __importDefault(require("../libs/formatNb"));
|
|
43
|
+
var ui_1 = require("../ui");
|
|
44
|
+
function Time(_a) {
|
|
45
|
+
var length = _a.length, onScrollEnd = _a.onScrollEnd, color = _a.color, _b = _a.index, index = _b === void 0 ? 0 : _b, _c = _a.height, height = _c === void 0 ? 46 : _c, _d = _a.start, start = _d === void 0 ? 0 : _d;
|
|
46
|
+
var flatListRef = (0, react_1.useRef)(null);
|
|
47
|
+
var data = (0, react_1.useMemo)(function () {
|
|
48
|
+
var data = Array.from({ length: length });
|
|
49
|
+
if (start)
|
|
50
|
+
data = data.map(function (_, i) { return i + start; });
|
|
51
|
+
return data;
|
|
52
|
+
}, [start]);
|
|
53
|
+
(0, react_1.useEffect)(function () {
|
|
54
|
+
var _a;
|
|
55
|
+
if (start)
|
|
56
|
+
index = data.findIndex(function (d) { return d === index; });
|
|
57
|
+
(_a = flatListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex({ index: index, animated: true });
|
|
58
|
+
}, [flatListRef.current, data, start, index]);
|
|
59
|
+
var onMomentumScrollEnd = function (event) {
|
|
60
|
+
var _a = event.nativeEvent, contentOffset = _a.contentOffset, layoutMeasurement = _a.layoutMeasurement;
|
|
61
|
+
var value = Math.round(contentOffset.y / layoutMeasurement.height);
|
|
62
|
+
if (start)
|
|
63
|
+
value = Number(data[value]);
|
|
64
|
+
onScrollEnd === null || onScrollEnd === void 0 ? void 0 : onScrollEnd(value);
|
|
65
|
+
};
|
|
66
|
+
var onScrollEndDrag = function (event) {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
var contentOffset = event.nativeEvent.contentOffset;
|
|
69
|
+
var currentIndex = Math.round(contentOffset.y / height);
|
|
70
|
+
if (currentIndex === -1) {
|
|
71
|
+
(_a = flatListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex({
|
|
72
|
+
index: data.length - 1,
|
|
73
|
+
animated: false,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else if (currentIndex === data.length) {
|
|
77
|
+
(_b = flatListRef.current) === null || _b === void 0 ? void 0 : _b.scrollToIndex({
|
|
78
|
+
index: 0,
|
|
79
|
+
animated: false,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return (<react_native_1.FlatList pagingEnabled ref={flatListRef} data={data} showsVerticalScrollIndicator={false} onScrollEndDrag={onScrollEndDrag} onMomentumScrollEnd={onMomentumScrollEnd} renderItem={function (_a) {
|
|
84
|
+
var item = _a.item, index = _a.index;
|
|
85
|
+
return (<ui_1.KView height={height} justifyContent="center" alignItems="center">
|
|
86
|
+
<ui_1.KText fontSize={24} fontWeight="bold" color={color}>
|
|
87
|
+
{(0, formatNb_1.default)(item || index)}
|
|
88
|
+
</ui_1.KText>
|
|
89
|
+
</ui_1.KView>);
|
|
90
|
+
}} getItemLayout={function (_, index) { return ({
|
|
91
|
+
length: height,
|
|
92
|
+
offset: height * index,
|
|
93
|
+
index: index,
|
|
94
|
+
}); }}/>);
|
|
95
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
date: Date;
|
|
4
|
+
showDate?: boolean;
|
|
5
|
+
onChangeHours?: (hours: number) => void;
|
|
6
|
+
onChangeMinutes?: (minutes: number) => void;
|
|
7
|
+
color?: string;
|
|
8
|
+
};
|
|
9
|
+
export default function TimeView({ date, onChangeHours, onChangeMinutes, showDate, color, }: Props): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
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 = TimeView;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var format_1 = require("../libs/format");
|
|
9
|
+
var ui_1 = require("../ui");
|
|
10
|
+
var Time_1 = __importDefault(require("./Time"));
|
|
11
|
+
function TimeView(_a) {
|
|
12
|
+
var date = _a.date, onChangeHours = _a.onChangeHours, onChangeMinutes = _a.onChangeMinutes, showDate = _a.showDate, color = _a.color;
|
|
13
|
+
return (<ui_1.KView flexDirection="row" height={54} backgroundColor={"".concat(color, "11")} alignItems="center" width={120} alignSelf="center" paddingHorizontal={8} paddingVertical={4}
|
|
14
|
+
// borderWidth={3}
|
|
15
|
+
borderColor={"".concat(color, "11")}>
|
|
16
|
+
{showDate && (<ui_1.KView backgroundColor={color} paddingHorizontal={10} paddingVertical={1} position="absolute" top={-12} left={19} borderWidth={1} borderColor="white">
|
|
17
|
+
<ui_1.KText color="white">{(0, format_1.formatShortDate)(date)}</ui_1.KText>
|
|
18
|
+
</ui_1.KView>)}
|
|
19
|
+
<Time_1.default length={24} index={date.getHours()} onScrollEnd={onChangeHours} color={color}/>
|
|
20
|
+
<ui_1.KText fontSize={18} textAlign="center" fontWeight="bold" color={color}>
|
|
21
|
+
h
|
|
22
|
+
</ui_1.KText>
|
|
23
|
+
<Time_1.default length={60} index={date.getMinutes()} onScrollEnd={onChangeMinutes} color={color}/>
|
|
24
|
+
</ui_1.KView>);
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = useCalendarDisclose;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
function useCalendarDisclose() {
|
|
6
|
+
var _a = (0, react_1.useState)(false), isOpen = _a[0], setIsOpen = _a[1];
|
|
7
|
+
var onToggle = function () { return setIsOpen(function (v) { return !v; }); };
|
|
8
|
+
return { isOpen: isOpen, onToggle: onToggle };
|
|
9
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function formatDate(date: Date, locales?: Intl.LocalesArgument, mode?: "date" | "time" | "datetime"): string;
|
|
2
|
+
export declare function formatMonth(date: Date, locales?: Intl.LocalesArgument): string;
|
|
3
|
+
export declare function formatShortDate(date: Date, locales?: Intl.LocalesArgument): string;
|
|
4
|
+
export declare const getWeekDay: (date: Date, locales?: Intl.LocalesArgument) => string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWeekDay = void 0;
|
|
4
|
+
exports.formatDate = formatDate;
|
|
5
|
+
exports.formatMonth = formatMonth;
|
|
6
|
+
exports.formatShortDate = formatShortDate;
|
|
7
|
+
function formatDate(date, locales, mode) {
|
|
8
|
+
if (locales === void 0) { locales = "fr-FR"; }
|
|
9
|
+
if (mode === void 0) { mode = "date"; }
|
|
10
|
+
switch (mode) {
|
|
11
|
+
case "time":
|
|
12
|
+
return date.toLocaleTimeString(locales, {
|
|
13
|
+
hour: "2-digit",
|
|
14
|
+
minute: "2-digit",
|
|
15
|
+
});
|
|
16
|
+
case "date":
|
|
17
|
+
return date.toLocaleDateString(locales, {
|
|
18
|
+
day: "2-digit",
|
|
19
|
+
month: "2-digit",
|
|
20
|
+
year: "numeric",
|
|
21
|
+
});
|
|
22
|
+
case "datetime":
|
|
23
|
+
return date.toLocaleDateString(locales, {
|
|
24
|
+
day: "2-digit",
|
|
25
|
+
month: "2-digit",
|
|
26
|
+
year: "numeric",
|
|
27
|
+
hour: "2-digit",
|
|
28
|
+
minute: "2-digit",
|
|
29
|
+
});
|
|
30
|
+
default:
|
|
31
|
+
return "Invalid mode";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function formatMonth(date, locales) {
|
|
35
|
+
if (locales === void 0) { locales = "fr-FR"; }
|
|
36
|
+
return date.toLocaleDateString(locales, {
|
|
37
|
+
month: "long",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function formatShortDate(date, locales) {
|
|
41
|
+
if (locales === void 0) { locales = "fr-FR"; }
|
|
42
|
+
return date.toLocaleDateString(locales, {
|
|
43
|
+
day: "2-digit",
|
|
44
|
+
month: "2-digit",
|
|
45
|
+
year: "2-digit",
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
var getWeekDay = function (date, locales) {
|
|
49
|
+
if (locales === void 0) { locales = "fr-FR"; }
|
|
50
|
+
return date.toLocaleString(locales, { weekday: "short" }).slice(0, 3);
|
|
51
|
+
};
|
|
52
|
+
exports.getWeekDay = getWeekDay;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function formatNb(nb: number): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getDayMatrix(value: Date): Date[][];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = getDayMatrix;
|
|
4
|
+
function getDayMatrix(value) {
|
|
5
|
+
var year = value.getFullYear();
|
|
6
|
+
var month = value.getMonth();
|
|
7
|
+
var offset = new Date(year, month, 1).getDay() - 1;
|
|
8
|
+
var getDate = function (date) { return new Date(year, month, date - offset); };
|
|
9
|
+
return [
|
|
10
|
+
[
|
|
11
|
+
getDate(1),
|
|
12
|
+
getDate(8),
|
|
13
|
+
getDate(15),
|
|
14
|
+
getDate(22),
|
|
15
|
+
getDate(29),
|
|
16
|
+
getDate(36),
|
|
17
|
+
getDate(43),
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
getDate(2),
|
|
21
|
+
getDate(9),
|
|
22
|
+
getDate(16),
|
|
23
|
+
getDate(23),
|
|
24
|
+
getDate(30),
|
|
25
|
+
getDate(37),
|
|
26
|
+
getDate(44),
|
|
27
|
+
],
|
|
28
|
+
[
|
|
29
|
+
getDate(3),
|
|
30
|
+
getDate(10),
|
|
31
|
+
getDate(17),
|
|
32
|
+
getDate(24),
|
|
33
|
+
getDate(31),
|
|
34
|
+
getDate(38),
|
|
35
|
+
getDate(45),
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
getDate(4),
|
|
39
|
+
getDate(11),
|
|
40
|
+
getDate(18),
|
|
41
|
+
getDate(25),
|
|
42
|
+
getDate(32),
|
|
43
|
+
getDate(39),
|
|
44
|
+
getDate(46),
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
getDate(5),
|
|
48
|
+
getDate(12),
|
|
49
|
+
getDate(19),
|
|
50
|
+
getDate(26),
|
|
51
|
+
getDate(33),
|
|
52
|
+
getDate(40),
|
|
53
|
+
getDate(47),
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
getDate(6),
|
|
57
|
+
getDate(13),
|
|
58
|
+
getDate(20),
|
|
59
|
+
getDate(27),
|
|
60
|
+
getDate(34),
|
|
61
|
+
getDate(41),
|
|
62
|
+
getDate(48),
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
getDate(0),
|
|
66
|
+
getDate(7),
|
|
67
|
+
getDate(14),
|
|
68
|
+
getDate(21),
|
|
69
|
+
getDate(28),
|
|
70
|
+
getDate(35),
|
|
71
|
+
getDate(42),
|
|
72
|
+
],
|
|
73
|
+
];
|
|
74
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DateValueType } from "../Calendar2k.types";
|
|
2
|
+
declare const getStatus: ({ date, shortDate, selectedDate }: ArgType) => {
|
|
3
|
+
isToday: boolean;
|
|
4
|
+
isStartBorn: boolean;
|
|
5
|
+
isEndBorn: boolean;
|
|
6
|
+
isSelected: boolean;
|
|
7
|
+
isForCurrentMonth: boolean;
|
|
8
|
+
};
|
|
9
|
+
export default getStatus;
|
|
10
|
+
type ArgType = {
|
|
11
|
+
date: Date;
|
|
12
|
+
shortDate: Date;
|
|
13
|
+
selectedDate?: DateValueType;
|
|
14
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
var isToday_1 = __importDefault(require("./isToday"));
|
|
7
|
+
var resetTime_1 = __importDefault(require("./resetTime"));
|
|
8
|
+
var getStatus = function (_a) {
|
|
9
|
+
var date = _a.date, shortDate = _a.shortDate, selectedDate = _a.selectedDate;
|
|
10
|
+
var status = {
|
|
11
|
+
isToday: (0, isToday_1.default)(date),
|
|
12
|
+
isStartBorn: false,
|
|
13
|
+
isEndBorn: false,
|
|
14
|
+
isSelected: false,
|
|
15
|
+
isForCurrentMonth: date.getMonth() === shortDate.getMonth(),
|
|
16
|
+
};
|
|
17
|
+
if (selectedDate instanceof Date) {
|
|
18
|
+
var valueDate = (0, resetTime_1.default)(selectedDate);
|
|
19
|
+
status.isSelected = date.getTime() === valueDate.getTime();
|
|
20
|
+
}
|
|
21
|
+
else if (selectedDate instanceof Object &&
|
|
22
|
+
selectedDate.start instanceof Date) {
|
|
23
|
+
var start = (0, resetTime_1.default)(selectedDate.start);
|
|
24
|
+
status.isStartBorn = start.getTime() === date.getTime();
|
|
25
|
+
if (selectedDate.end) {
|
|
26
|
+
var end = (0, resetTime_1.default)(selectedDate.end);
|
|
27
|
+
status.isSelected = start <= date && date <= end;
|
|
28
|
+
if (status.isSelected)
|
|
29
|
+
status.isEndBorn = date.getTime() === end.getTime();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
status.isSelected = status.isStartBorn;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return status;
|
|
36
|
+
};
|
|
37
|
+
exports.default = getStatus;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
import { DateValueType } from "../Calendar2k.types";
|
|
3
|
+
declare const getStyle: ({ date, shortDate, selectedDate, color, active, }: ArgType) => {
|
|
4
|
+
touchableOpacity: ViewStyle;
|
|
5
|
+
text: TextStyle;
|
|
6
|
+
};
|
|
7
|
+
export default getStyle;
|
|
8
|
+
type ArgType = {
|
|
9
|
+
date: Date;
|
|
10
|
+
shortDate: Date;
|
|
11
|
+
active?: boolean;
|
|
12
|
+
selectedDate?: DateValueType;
|
|
13
|
+
color?: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
var getStatus_1 = __importDefault(require("./getStatus"));
|
|
7
|
+
var getStyle = function (_a) {
|
|
8
|
+
var date = _a.date, shortDate = _a.shortDate, selectedDate = _a.selectedDate, color = _a.color, active = _a.active;
|
|
9
|
+
var status = (0, getStatus_1.default)({ date: date, shortDate: shortDate, selectedDate: selectedDate });
|
|
10
|
+
var style = { touchableOpacity: {}, text: {} };
|
|
11
|
+
style.text.color = color;
|
|
12
|
+
if (!status.isForCurrentMonth)
|
|
13
|
+
style.text.color = "".concat(color, "55");
|
|
14
|
+
if (!active)
|
|
15
|
+
style.text.color = "".concat(color, "22");
|
|
16
|
+
if (status.isToday) {
|
|
17
|
+
style.touchableOpacity.backgroundColor = color;
|
|
18
|
+
style.text.color = "white";
|
|
19
|
+
style.text.fontWeight = "bold";
|
|
20
|
+
}
|
|
21
|
+
if (status.isSelected) {
|
|
22
|
+
style.touchableOpacity.backgroundColor = "".concat(color, "22");
|
|
23
|
+
style.text.fontWeight = "bold";
|
|
24
|
+
}
|
|
25
|
+
if (status.isStartBorn) {
|
|
26
|
+
style.touchableOpacity.borderTopLeftRadius = 10;
|
|
27
|
+
style.touchableOpacity.borderBottomLeftRadius = 10;
|
|
28
|
+
}
|
|
29
|
+
if (status.isEndBorn) {
|
|
30
|
+
style.touchableOpacity.borderTopRightRadius = 10;
|
|
31
|
+
style.touchableOpacity.borderBottomRightRadius = 10;
|
|
32
|
+
}
|
|
33
|
+
return style;
|
|
34
|
+
};
|
|
35
|
+
exports.default = getStyle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = isActive;
|
|
4
|
+
function isActive(_a) {
|
|
5
|
+
var min = _a.min, max = _a.max, date = _a.date, disableDate = _a.disableDate;
|
|
6
|
+
if (!date)
|
|
7
|
+
return false;
|
|
8
|
+
if (min && max)
|
|
9
|
+
return date.getTime() >= min.getTime() && date.getTime() <= max.getTime();
|
|
10
|
+
if (min)
|
|
11
|
+
return date.getTime() >= min.getTime();
|
|
12
|
+
if (max)
|
|
13
|
+
return date.getTime() <= max.getTime();
|
|
14
|
+
if (disableDate)
|
|
15
|
+
return !disableDate(date);
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isToday(date: Date): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = isToday;
|
|
4
|
+
function isToday(date) {
|
|
5
|
+
var today = new Date();
|
|
6
|
+
return (today.getDate() === date.getDate() &&
|
|
7
|
+
today.getMonth() === date.getMonth() &&
|
|
8
|
+
today.getFullYear() === date.getFullYear());
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function resetTime(date: Date): Date;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toHexColor(color?: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toHexColor = toHexColor;
|
|
4
|
+
var react_native_1 = require("react-native");
|
|
5
|
+
function toHexColor(color) {
|
|
6
|
+
if (!color)
|
|
7
|
+
return "#000000";
|
|
8
|
+
var processed = (0, react_native_1.processColor)(color);
|
|
9
|
+
if (!processed)
|
|
10
|
+
return "#000000";
|
|
11
|
+
var hex = processed.toString(16).padStart(8, "0");
|
|
12
|
+
return "#".concat(hex.slice(2));
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import { TextProps, TextStyle, TouchableOpacityProps, ViewProps, ViewStyle } from "react-native";
|
|
3
|
+
type KViewProps = ViewStyle & PropsWithChildren & {
|
|
4
|
+
nativeProps?: ViewProps;
|
|
5
|
+
};
|
|
6
|
+
export declare function KView({ nativeProps, children, ...style }: KViewProps): import("react").JSX.Element;
|
|
7
|
+
type KTouchableOpacityProps = ViewStyle & PropsWithChildren & {
|
|
8
|
+
nativeProps?: TouchableOpacityProps;
|
|
9
|
+
};
|
|
10
|
+
export declare function KTouchableOpacity({ nativeProps, children, ...style }: KTouchableOpacityProps): import("react").JSX.Element;
|
|
11
|
+
type KTextProps = TextStyle & PropsWithChildren & {
|
|
12
|
+
nativeProps?: TextProps;
|
|
13
|
+
};
|
|
14
|
+
export declare function KText({ nativeProps, children, ...style }: KTextProps): import("react").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.KView = KView;
|
|
15
|
+
exports.KTouchableOpacity = KTouchableOpacity;
|
|
16
|
+
exports.KText = KText;
|
|
17
|
+
var react_native_1 = require("react-native");
|
|
18
|
+
function KView(_a) {
|
|
19
|
+
var nativeProps = _a.nativeProps, children = _a.children, style = __rest(_a, ["nativeProps", "children"]);
|
|
20
|
+
return (<react_native_1.View style={style} {...nativeProps}>
|
|
21
|
+
{children}
|
|
22
|
+
</react_native_1.View>);
|
|
23
|
+
}
|
|
24
|
+
function KTouchableOpacity(_a) {
|
|
25
|
+
var nativeProps = _a.nativeProps, children = _a.children, style = __rest(_a, ["nativeProps", "children"]);
|
|
26
|
+
return (<react_native_1.TouchableOpacity style={style} {...nativeProps}>
|
|
27
|
+
{children}
|
|
28
|
+
</react_native_1.TouchableOpacity>);
|
|
29
|
+
}
|
|
30
|
+
function KText(_a) {
|
|
31
|
+
var nativeProps = _a.nativeProps, children = _a.children, style = __rest(_a, ["nativeProps", "children"]);
|
|
32
|
+
return (<react_native_1.Text style={style} {...nativeProps}>
|
|
33
|
+
{children}
|
|
34
|
+
</react_native_1.Text>);
|
|
35
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Pod::Spec.new do |s|
|
|
2
|
+
s.name = 'Calendar2k'
|
|
3
|
+
s.version = '1.0.0'
|
|
4
|
+
s.summary = 'A sample project summary'
|
|
5
|
+
s.description = 'A sample project description'
|
|
6
|
+
s.author = ''
|
|
7
|
+
s.homepage = 'https://docs.expo.dev/modules/'
|
|
8
|
+
s.platforms = {
|
|
9
|
+
:ios => '16.4',
|
|
10
|
+
:tvos => '16.4'
|
|
11
|
+
}
|
|
12
|
+
s.source = { git: '' }
|
|
13
|
+
s.static_framework = true
|
|
14
|
+
|
|
15
|
+
s.dependency 'ExpoModulesCore'
|
|
16
|
+
|
|
17
|
+
# Swift/Objective-C compatibility
|
|
18
|
+
s.pod_target_xcconfig = {
|
|
19
|
+
'DEFINES_MODULE' => 'YES',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
|
|
23
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
// This view will be used as a native component. Make sure to inherit from `ExpoView`
|
|
4
|
+
// to apply the proper styling (e.g. border radius and shadows).
|
|
5
|
+
class Calendar2kView: ExpoView {
|
|
6
|
+
let label = UILabel()
|
|
7
|
+
|
|
8
|
+
required init(appContext: AppContext? = nil) {
|
|
9
|
+
super.init(appContext: appContext)
|
|
10
|
+
clipsToBounds = true
|
|
11
|
+
backgroundColor = UIColor(red: 0.67, green: 0.73, blue: 0.80, alpha: 1.0)
|
|
12
|
+
label.text = "Calendar2k - native view"
|
|
13
|
+
label.textAlignment = .center
|
|
14
|
+
label.numberOfLines = 0
|
|
15
|
+
label.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
16
|
+
addSubview(label)
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-2k-datetime-picker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The fastest fully customizable Expo date & time picker, written in TypeScript, supporting Expo Go, single date, time, date range, time range, datetime range selection, flexible date disabling, and dynamic color theming for iOS and Android.",
|
|
5
|
+
"main": "build/Calendar2kView.js",
|
|
6
|
+
"types": "build/Calendar2k.types.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc && cp -r src/assets build/assets",
|
|
9
|
+
"release": "npm run build && npm version patch && npm publish --access public"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./build/Calendar2kView.js",
|
|
14
|
+
"require": "./build/Calendar2kView.js",
|
|
15
|
+
"types": "./build/Calendar2k.types.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"expo",
|
|
20
|
+
"expo-module",
|
|
21
|
+
"react-native",
|
|
22
|
+
"date-picker",
|
|
23
|
+
"time-picker",
|
|
24
|
+
"datetime-picker",
|
|
25
|
+
"date-range-picker",
|
|
26
|
+
"time-range-picker",
|
|
27
|
+
"datetime-range-picker",
|
|
28
|
+
"date-range",
|
|
29
|
+
"time-range",
|
|
30
|
+
"range-picker",
|
|
31
|
+
"calendar",
|
|
32
|
+
"datepicker",
|
|
33
|
+
"timepicker",
|
|
34
|
+
"picker",
|
|
35
|
+
"disable-dates",
|
|
36
|
+
"blocked-dates",
|
|
37
|
+
"custom-theme",
|
|
38
|
+
"color-theme",
|
|
39
|
+
"themeable",
|
|
40
|
+
"customizable",
|
|
41
|
+
"ios",
|
|
42
|
+
"android",
|
|
43
|
+
"native",
|
|
44
|
+
"schedule",
|
|
45
|
+
"booking",
|
|
46
|
+
"reservation",
|
|
47
|
+
"timestamp",
|
|
48
|
+
"expo-calendar",
|
|
49
|
+
"expo-go",
|
|
50
|
+
"expo-go-compatible"
|
|
51
|
+
],
|
|
52
|
+
"license": "MIT"
|
|
53
|
+
}
|