react-native-timer-picker 1.0.0 → 1.1.1
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 +386 -2
- package/package.json +41 -8
- package/dist/components/DurationPicker/DurationPicker.styles.d.ts +0 -26
- package/dist/components/DurationPicker/DurationPicker.styles.js +0 -39
- package/dist/components/DurationPicker/DurationScroll.d.ts +0 -16
- package/dist/components/DurationPicker/DurationScroll.js +0 -121
- package/dist/components/DurationPicker/index.d.ts +0 -27
- package/dist/components/DurationPicker/index.js +0 -55
- package/dist/components/DurationPickerModal.styles.d.ts +0 -23
- package/dist/components/DurationPickerModal.styles.js +0 -40
- package/dist/components/Modal/Modal.styles.d.ts +0 -22
- package/dist/components/Modal/Modal.styles.js +0 -26
- package/dist/components/Modal/index.d.ts +0 -14
- package/dist/components/Modal/index.js +0 -121
- package/dist/components/TimerPicker/DurationScroll.d.ts +0 -16
- package/dist/components/TimerPicker/DurationScroll.js +0 -121
- package/dist/components/TimerPicker/TimerPicker.styles.d.ts +0 -26
- package/dist/components/TimerPicker/TimerPicker.styles.js +0 -40
- package/dist/components/TimerPicker/index.d.ts +0 -27
- package/dist/components/TimerPicker/index.js +0 -56
- package/dist/components/TimerPickerModal.styles.d.ts +0 -23
- package/dist/components/TimerPickerModal.styles.js +0 -41
- package/dist/components/index.d.ts +0 -28
- package/dist/components/index.js +0 -87
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -10
- package/dist/utils/colorToRgba.d.ts +0 -4
- package/dist/utils/colorToRgba.js +0 -48
- package/dist/utils/generateNumbers.d.ts +0 -7
- package/dist/utils/generateNumbers.js +0 -27
- package/dist/utils/padWithZero.d.ts +0 -1
- package/dist/utils/padWithZero.js +0 -12
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.generateStyles = void 0;
|
|
15
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
16
|
-
var react_native_1 = require("react-native");
|
|
17
|
-
var DARK_MODE_BACKGROUND_COLOR = "#232323";
|
|
18
|
-
var DARK_MODE_TEXT_COLOR = "#E9E9E9";
|
|
19
|
-
var LIGHT_MODE_BACKGROUND_COLOR = "#F1F1F1";
|
|
20
|
-
var LIGHT_MODE_TEXT_COLOR = "#1B1B1B";
|
|
21
|
-
var generateStyles = function (customStyles, options) {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
23
|
-
return react_native_1.StyleSheet.create({
|
|
24
|
-
pickerContainer: __assign({ flexDirection: "row", marginRight: "8%", backgroundColor: (_a = customStyles === null || customStyles === void 0 ? void 0 : customStyles.backgroundColor) !== null && _a !== void 0 ? _a : ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark"
|
|
25
|
-
? DARK_MODE_BACKGROUND_COLOR
|
|
26
|
-
: LIGHT_MODE_BACKGROUND_COLOR) }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerContainer),
|
|
27
|
-
pickerLabelContainer: __assign({ position: "absolute", right: 4, top: 0, bottom: 0, justifyContent: "center" }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerLabelContainer),
|
|
28
|
-
pickerLabel: __assign({ fontSize: 18, fontWeight: "bold", marginTop: ((_c = (_b = customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItem) === null || _b === void 0 ? void 0 : _b.fontSize) !== null && _c !== void 0 ? _c : 25) / 6, color: (_d = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _d !== void 0 ? _d : ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark"
|
|
29
|
-
? DARK_MODE_TEXT_COLOR
|
|
30
|
-
: LIGHT_MODE_TEXT_COLOR) }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerLabel),
|
|
31
|
-
pickerItemContainer: __assign({ height: 50, justifyContent: "center", alignItems: "center", width: ((_f = (_e = customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItem) === null || _e === void 0 ? void 0 : _e.fontSize) !== null && _f !== void 0 ? _f : 25) * 3.6 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItemContainer),
|
|
32
|
-
pickerItem: __assign({ textAlignVertical: "center", fontSize: 25, color: (_g = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _g !== void 0 ? _g : ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark"
|
|
33
|
-
? DARK_MODE_TEXT_COLOR
|
|
34
|
-
: LIGHT_MODE_TEXT_COLOR) }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItem),
|
|
35
|
-
pickerGradientOverlay: __assign({ position: "absolute", left: 0, right: 0, height: options.padWithNItems === 0
|
|
36
|
-
? "30%"
|
|
37
|
-
: ((_j = (_h = customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItemContainer) === null || _h === void 0 ? void 0 : _h.height) !== null && _j !== void 0 ? _j : 50) * 0.8 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerGradientOverlay),
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
exports.generateStyles = generateStyles;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
import { LinearGradient } from "expo-linear-gradient";
|
|
4
|
-
import { CustomTimerPickerStyles } from "./TimerPicker.styles";
|
|
5
|
-
export interface TimerPickerProps {
|
|
6
|
-
onDurationChange?: (duration: {
|
|
7
|
-
hours: number;
|
|
8
|
-
minutes: number;
|
|
9
|
-
seconds: number;
|
|
10
|
-
}) => void;
|
|
11
|
-
initialHours?: number;
|
|
12
|
-
initialMinutes?: number;
|
|
13
|
-
initialSeconds?: number;
|
|
14
|
-
hideHours?: boolean;
|
|
15
|
-
hideMinutes?: boolean;
|
|
16
|
-
hideSeconds?: boolean;
|
|
17
|
-
hourLabel?: string;
|
|
18
|
-
minuteLabel?: string;
|
|
19
|
-
secondLabel?: string;
|
|
20
|
-
padWithNItems?: number;
|
|
21
|
-
disableInfiniteScroll?: boolean;
|
|
22
|
-
pickerContainerProps?: React.ComponentProps<typeof View>;
|
|
23
|
-
pickerGradientOverlayProps?: React.ComponentProps<typeof LinearGradient>;
|
|
24
|
-
styles?: CustomTimerPickerStyles;
|
|
25
|
-
}
|
|
26
|
-
declare const TimerPicker: ({ onDurationChange, initialHours, initialMinutes, initialSeconds, hideHours, hideMinutes, hideSeconds, hourLabel, minuteLabel, secondLabel, padWithNItems, disableInfiniteScroll, pickerContainerProps, pickerGradientOverlayProps, styles: customStyles, }: TimerPickerProps) => React.ReactElement;
|
|
27
|
-
export default TimerPicker;
|
|
@@ -1,56 +0,0 @@
|
|
|
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
var react_1 = __importStar(require("react"));
|
|
30
|
-
var react_native_1 = require("react-native");
|
|
31
|
-
var DurationScroll_1 = __importDefault(require("./DurationScroll"));
|
|
32
|
-
var TimerPicker_styles_1 = require("./TimerPicker.styles");
|
|
33
|
-
var TimerPicker = function (_a) {
|
|
34
|
-
var onDurationChange = _a.onDurationChange, _b = _a.initialHours, initialHours = _b === void 0 ? 0 : _b, _c = _a.initialMinutes, initialMinutes = _c === void 0 ? 0 : _c, _d = _a.initialSeconds, initialSeconds = _d === void 0 ? 0 : _d, _e = _a.hideHours, hideHours = _e === void 0 ? false : _e, _f = _a.hideMinutes, hideMinutes = _f === void 0 ? false : _f, _g = _a.hideSeconds, hideSeconds = _g === void 0 ? false : _g, _h = _a.hourLabel, hourLabel = _h === void 0 ? "h" : _h, _j = _a.minuteLabel, minuteLabel = _j === void 0 ? "m" : _j, _k = _a.secondLabel, secondLabel = _k === void 0 ? "s" : _k, _l = _a.padWithNItems, padWithNItems = _l === void 0 ? 1 : _l, _m = _a.disableInfiniteScroll, disableInfiniteScroll = _m === void 0 ? false : _m, pickerContainerProps = _a.pickerContainerProps, pickerGradientOverlayProps = _a.pickerGradientOverlayProps, customStyles = _a.styles;
|
|
35
|
-
var checkedPadWithNItems = padWithNItems >= 0 ? Math.round(padWithNItems) : 0;
|
|
36
|
-
var styles = (0, TimerPicker_styles_1.generateStyles)(customStyles, {
|
|
37
|
-
padWithNItems: checkedPadWithNItems,
|
|
38
|
-
});
|
|
39
|
-
var _o = (0, react_1.useState)(initialHours), selectedHours = _o[0], setSelectedHours = _o[1];
|
|
40
|
-
var _p = (0, react_1.useState)(initialMinutes), selectedMinutes = _p[0], setSelectedMinutes = _p[1];
|
|
41
|
-
var _q = (0, react_1.useState)(initialSeconds), selectedSeconds = _q[0], setSelectedSeconds = _q[1];
|
|
42
|
-
(0, react_1.useEffect)(function () {
|
|
43
|
-
onDurationChange === null || onDurationChange === void 0 ? void 0 : onDurationChange({
|
|
44
|
-
hours: selectedHours,
|
|
45
|
-
minutes: selectedMinutes,
|
|
46
|
-
seconds: selectedSeconds,
|
|
47
|
-
});
|
|
48
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
-
}, [selectedHours, selectedMinutes, selectedSeconds]);
|
|
50
|
-
return (<react_native_1.View {...pickerContainerProps} style={styles.pickerContainer}>
|
|
51
|
-
{!hideHours ? (<DurationScroll_1.default numberOfItems={23} label={hourLabel} initialIndex={initialHours} onDurationChange={setSelectedHours} pickerGradientOverlayProps={pickerGradientOverlayProps} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} styles={styles}/>) : null}
|
|
52
|
-
{!hideMinutes ? (<DurationScroll_1.default numberOfItems={59} label={minuteLabel} initialIndex={initialMinutes} onDurationChange={setSelectedMinutes} padNumbersWithZero pickerGradientOverlayProps={pickerGradientOverlayProps} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} styles={styles}/>) : null}
|
|
53
|
-
{!hideSeconds ? (<DurationScroll_1.default numberOfItems={59} label={secondLabel} initialIndex={initialSeconds} onDurationChange={setSelectedSeconds} padNumbersWithZero pickerGradientOverlayProps={pickerGradientOverlayProps} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} styles={styles}/>) : null}
|
|
54
|
-
</react_native_1.View>);
|
|
55
|
-
};
|
|
56
|
-
exports.default = TimerPicker;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { CustomTimerPickerStyles } from "./TimerPicker/TimerPicker.styles";
|
|
2
|
-
export interface CustomTimerPickerModalStyles extends CustomTimerPickerStyles {
|
|
3
|
-
container?: any;
|
|
4
|
-
contentContainer?: any;
|
|
5
|
-
pickerContainer?: any;
|
|
6
|
-
pickerLabel?: any;
|
|
7
|
-
pickerItemContainer?: any;
|
|
8
|
-
pickerItem?: any;
|
|
9
|
-
buttonContainer?: any;
|
|
10
|
-
button?: any;
|
|
11
|
-
cancelButton?: any;
|
|
12
|
-
confirmButton?: any;
|
|
13
|
-
modalTitle?: any;
|
|
14
|
-
}
|
|
15
|
-
export declare const generateStyles: (customStyles: CustomTimerPickerModalStyles | undefined) => {
|
|
16
|
-
container: any;
|
|
17
|
-
contentContainer: any;
|
|
18
|
-
buttonContainer: any;
|
|
19
|
-
button: any;
|
|
20
|
-
cancelButton: any;
|
|
21
|
-
confirmButton: any;
|
|
22
|
-
modalTitle: any;
|
|
23
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.generateStyles = void 0;
|
|
15
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
16
|
-
var react_native_1 = require("react-native");
|
|
17
|
-
var DARK_MODE_BACKGROUND_COLOR = "#232323";
|
|
18
|
-
var DARK_MODE_TEXT_COLOR = "#E9E9E9";
|
|
19
|
-
var LIGHT_MODE_BACKGROUND_COLOR = "#F1F1F1";
|
|
20
|
-
var LIGHT_MODE_TEXT_COLOR = "#1B1B1B";
|
|
21
|
-
var generateStyles = function (customStyles) {
|
|
22
|
-
var _a, _b, _c, _d;
|
|
23
|
-
return react_native_1.StyleSheet.create({
|
|
24
|
-
container: __assign({ flex: 1, justifyContent: "center", alignItems: "center" }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.container),
|
|
25
|
-
contentContainer: __assign({ backgroundColor: ((_a = customStyles === null || customStyles === void 0 ? void 0 : customStyles.backgroundColor) !== null && _a !== void 0 ? _a : (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark")
|
|
26
|
-
? DARK_MODE_BACKGROUND_COLOR
|
|
27
|
-
: LIGHT_MODE_BACKGROUND_COLOR, justifyContent: "center", alignItems: "center", borderRadius: 20, padding: 20 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.contentContainer),
|
|
28
|
-
buttonContainer: __assign({ flexDirection: "row", marginTop: 25 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.buttonContainer),
|
|
29
|
-
button: __assign({ marginHorizontal: 12, paddingVertical: 10, paddingHorizontal: 20, borderWidth: 1, borderRadius: 10, fontSize: 16, overflow: "hidden" }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.button),
|
|
30
|
-
cancelButton: __assign({ borderColor: "gray", color: ((_b = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _b !== void 0 ? _b : (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark")
|
|
31
|
-
? DARK_MODE_TEXT_COLOR
|
|
32
|
-
: "gray", backgroundColor: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? "gray" : undefined }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.cancelButton),
|
|
33
|
-
confirmButton: __assign({ borderColor: "green", color: ((_c = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _c !== void 0 ? _c : (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark")
|
|
34
|
-
? DARK_MODE_TEXT_COLOR
|
|
35
|
-
: "green", backgroundColor: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? "green" : undefined }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.confirmButton),
|
|
36
|
-
modalTitle: __assign({ fontSize: 24, fontWeight: "bold", marginBottom: 15, color: ((_d = customStyles === null || customStyles === void 0 ? void 0 : customStyles.textColor) !== null && _d !== void 0 ? _d : (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark")
|
|
37
|
-
? DARK_MODE_TEXT_COLOR
|
|
38
|
-
: LIGHT_MODE_TEXT_COLOR }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.modalTitle),
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
exports.generateStyles = generateStyles;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View, Text } from "react-native";
|
|
3
|
-
import { TimerPickerProps } from "./TimerPicker";
|
|
4
|
-
import Modal from "./Modal";
|
|
5
|
-
import { CustomTimerPickerModalStyles } from "./TimerPickerModal.styles";
|
|
6
|
-
export interface TimerPickerModalProps extends Omit<TimerPickerProps, "onDurationChange"> {
|
|
7
|
-
visible: boolean;
|
|
8
|
-
setIsVisible: (isVisible: boolean) => void;
|
|
9
|
-
onConfirm: ({ hours, minutes, seconds, }: {
|
|
10
|
-
hours: number;
|
|
11
|
-
minutes: number;
|
|
12
|
-
seconds: number;
|
|
13
|
-
}) => void;
|
|
14
|
-
onCancel: () => void;
|
|
15
|
-
closeOnOverlayPress?: boolean;
|
|
16
|
-
hideCancelButton?: boolean;
|
|
17
|
-
confirmButtonText?: string;
|
|
18
|
-
cancelButtonText?: string;
|
|
19
|
-
modalTitle?: string;
|
|
20
|
-
modalProps?: React.ComponentProps<typeof Modal>;
|
|
21
|
-
containerProps?: React.ComponentProps<typeof View>;
|
|
22
|
-
contentContainerProps?: React.ComponentProps<typeof View>;
|
|
23
|
-
buttonContainerProps?: React.ComponentProps<typeof View>;
|
|
24
|
-
modalTitleProps?: React.ComponentProps<typeof Text>;
|
|
25
|
-
styles?: CustomTimerPickerModalStyles;
|
|
26
|
-
}
|
|
27
|
-
declare const TimerPickerModal: ({ visible, setIsVisible, onConfirm, onCancel, closeOnOverlayPress, initialHours, initialMinutes, initialSeconds, hideHours, hideMinutes, hideSeconds, hourLabel, minuteLabel, secondLabel, padWithNItems, disableInfiniteScroll, hideCancelButton, confirmButtonText, cancelButtonText, modalTitle, modalProps, containerProps, contentContainerProps, pickerContainerProps, buttonContainerProps, modalTitleProps, pickerGradientOverlayProps, styles: customStyles, }: TimerPickerModalProps) => React.ReactElement;
|
|
28
|
-
export default TimerPickerModal;
|
package/dist/components/index.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
var react_1 = __importStar(require("react"));
|
|
30
|
-
var react_native_1 = require("react-native");
|
|
31
|
-
var TimerPicker_1 = __importDefault(require("./TimerPicker"));
|
|
32
|
-
var Modal_1 = __importDefault(require("./Modal"));
|
|
33
|
-
var TimerPickerModal_styles_1 = require("./TimerPickerModal.styles");
|
|
34
|
-
var TimerPickerModal = function (_a) {
|
|
35
|
-
var visible = _a.visible, setIsVisible = _a.setIsVisible, onConfirm = _a.onConfirm, onCancel = _a.onCancel, closeOnOverlayPress = _a.closeOnOverlayPress, _b = _a.initialHours, initialHours = _b === void 0 ? 0 : _b, _c = _a.initialMinutes, initialMinutes = _c === void 0 ? 0 : _c, _d = _a.initialSeconds, initialSeconds = _d === void 0 ? 0 : _d, _e = _a.hideHours, hideHours = _e === void 0 ? false : _e, _f = _a.hideMinutes, hideMinutes = _f === void 0 ? false : _f, _g = _a.hideSeconds, hideSeconds = _g === void 0 ? false : _g, _h = _a.hourLabel, hourLabel = _h === void 0 ? "h" : _h, _j = _a.minuteLabel, minuteLabel = _j === void 0 ? "m" : _j, _k = _a.secondLabel, secondLabel = _k === void 0 ? "s" : _k, _l = _a.padWithNItems, padWithNItems = _l === void 0 ? 1 : _l, _m = _a.disableInfiniteScroll, disableInfiniteScroll = _m === void 0 ? false : _m, _o = _a.hideCancelButton, hideCancelButton = _o === void 0 ? false : _o, _p = _a.confirmButtonText, confirmButtonText = _p === void 0 ? "Confirm" : _p, _q = _a.cancelButtonText, cancelButtonText = _q === void 0 ? "Cancel" : _q, modalTitle = _a.modalTitle, modalProps = _a.modalProps, containerProps = _a.containerProps, contentContainerProps = _a.contentContainerProps, pickerContainerProps = _a.pickerContainerProps, buttonContainerProps = _a.buttonContainerProps, modalTitleProps = _a.modalTitleProps, pickerGradientOverlayProps = _a.pickerGradientOverlayProps, customStyles = _a.styles;
|
|
36
|
-
var styles = (0, TimerPickerModal_styles_1.generateStyles)(customStyles);
|
|
37
|
-
var _r = (0, react_1.useState)({
|
|
38
|
-
hours: initialHours,
|
|
39
|
-
minutes: initialMinutes,
|
|
40
|
-
seconds: initialSeconds,
|
|
41
|
-
}), selectedDuration = _r[0], setSelectedDuration = _r[1];
|
|
42
|
-
var _s = (0, react_1.useState)({
|
|
43
|
-
hours: initialHours,
|
|
44
|
-
minutes: initialMinutes,
|
|
45
|
-
seconds: initialSeconds,
|
|
46
|
-
}), confirmedDuration = _s[0], setConfirmedDuration = _s[1];
|
|
47
|
-
var hideModal = function () {
|
|
48
|
-
setSelectedDuration({
|
|
49
|
-
hours: confirmedDuration.hours,
|
|
50
|
-
minutes: confirmedDuration.minutes,
|
|
51
|
-
seconds: confirmedDuration.seconds,
|
|
52
|
-
});
|
|
53
|
-
setIsVisible(false);
|
|
54
|
-
};
|
|
55
|
-
var confirm = function () {
|
|
56
|
-
onConfirm(selectedDuration);
|
|
57
|
-
setConfirmedDuration(selectedDuration);
|
|
58
|
-
};
|
|
59
|
-
return (<Modal_1.default isVisible={visible} onOverlayPress={closeOnOverlayPress ? hideModal : undefined} {...modalProps}>
|
|
60
|
-
<react_native_1.View {...containerProps} style={styles.container}>
|
|
61
|
-
<react_native_1.View {...contentContainerProps} style={styles.contentContainer}>
|
|
62
|
-
{modalTitle ? (<react_native_1.Text {...modalTitleProps} style={styles.modalTitle}>
|
|
63
|
-
{modalTitle}
|
|
64
|
-
</react_native_1.Text>) : null}
|
|
65
|
-
<TimerPicker_1.default onDurationChange={function (duration) {
|
|
66
|
-
return setSelectedDuration(duration);
|
|
67
|
-
}} initialHours={confirmedDuration.hours} initialMinutes={confirmedDuration.minutes} initialSeconds={confirmedDuration.seconds} hideHours={hideHours} hideMinutes={hideMinutes} hideSeconds={hideSeconds} hourLabel={hourLabel} minuteLabel={minuteLabel} secondLabel={secondLabel} padWithNItems={padWithNItems} disableInfiniteScroll={disableInfiniteScroll} pickerContainerProps={pickerContainerProps} pickerGradientOverlayProps={pickerGradientOverlayProps} styles={customStyles}/>
|
|
68
|
-
<react_native_1.View {...buttonContainerProps} style={styles.buttonContainer}>
|
|
69
|
-
{!hideCancelButton ? (<react_native_1.TouchableOpacity onPress={onCancel}>
|
|
70
|
-
<react_native_1.Text style={[
|
|
71
|
-
styles.cancelButton,
|
|
72
|
-
styles.button,
|
|
73
|
-
]}>
|
|
74
|
-
{cancelButtonText}
|
|
75
|
-
</react_native_1.Text>
|
|
76
|
-
</react_native_1.TouchableOpacity>) : null}
|
|
77
|
-
<react_native_1.TouchableOpacity onPress={confirm}>
|
|
78
|
-
<react_native_1.Text style={[styles.confirmButton, styles.button]}>
|
|
79
|
-
{confirmButtonText}
|
|
80
|
-
</react_native_1.Text>
|
|
81
|
-
</react_native_1.TouchableOpacity>
|
|
82
|
-
</react_native_1.View>
|
|
83
|
-
</react_native_1.View>
|
|
84
|
-
</react_native_1.View>
|
|
85
|
-
</Modal_1.default>);
|
|
86
|
-
};
|
|
87
|
-
exports.default = TimerPickerModal;
|
package/dist/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { default as TimerPickerModal, TimerPickerModalProps, } from "./components";
|
|
2
|
-
export { default as TimerPicker, TimerPickerProps, } from "./components/TimerPicker";
|
|
3
|
-
export { CustomTimerPickerModalStyles } from "./components/TimerPickerModal.styles";
|
|
4
|
-
export { CustomTimerPickerStyles } from "./components/TimerPicker/TimerPicker.styles";
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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.TimerPicker = exports.TimerPickerModal = void 0;
|
|
7
|
-
var components_1 = require("./components");
|
|
8
|
-
Object.defineProperty(exports, "TimerPickerModal", { enumerable: true, get: function () { return __importDefault(components_1).default; } });
|
|
9
|
-
var TimerPicker_1 = require("./components/TimerPicker");
|
|
10
|
-
Object.defineProperty(exports, "TimerPicker", { enumerable: true, get: function () { return __importDefault(TimerPicker_1).default; } });
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.colorToRgba = void 0;
|
|
4
|
-
var colorToRgba = function (variables) {
|
|
5
|
-
// this function is required for expo-linear-gradient on iOS. To fade to transparent, we need
|
|
6
|
-
// to be able to add opacity to the background color. Supplying 'transparent' does not work
|
|
7
|
-
// because that is actually a transparent black (rgba(0, 0, 0, 1)), which results in dodgy rendering
|
|
8
|
-
var color = variables.color, _a = variables.opacity, opacity = _a === void 0 ? 1 : _a;
|
|
9
|
-
// Handle named colors
|
|
10
|
-
var namedColors = {
|
|
11
|
-
transparent: "rgba(0, 0, 0, 0)",
|
|
12
|
-
black: "rgba(0, 0, 0, 1)",
|
|
13
|
-
white: "rgba(255, 255, 255, 1)",
|
|
14
|
-
blue: "rgba(0, 0, 255, 1)",
|
|
15
|
-
green: "rgba(0, 128, 0, 1)",
|
|
16
|
-
gray: "rgba(128, 128, 128, 1)",
|
|
17
|
-
red: "rgba(255, 0, 0, 1)",
|
|
18
|
-
};
|
|
19
|
-
if (color in namedColors) {
|
|
20
|
-
return namedColors[color];
|
|
21
|
-
}
|
|
22
|
-
// Handle RGB format
|
|
23
|
-
if (color.startsWith("rgb(")) {
|
|
24
|
-
var rgbValues = color
|
|
25
|
-
.replace("rgb(", "")
|
|
26
|
-
.replace(")", "")
|
|
27
|
-
.split(",")
|
|
28
|
-
.map(function (value) { return parseInt(value.trim(), 10); });
|
|
29
|
-
var r = rgbValues[0], g = rgbValues[1], b = rgbValues[2];
|
|
30
|
-
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
31
|
-
}
|
|
32
|
-
// Handle hex format
|
|
33
|
-
if (color.startsWith("#")) {
|
|
34
|
-
var hexColor = color.slice(1);
|
|
35
|
-
if (hexColor.length === 3) {
|
|
36
|
-
hexColor = hexColor
|
|
37
|
-
.split("")
|
|
38
|
-
.map(function (value) { return value + value; })
|
|
39
|
-
.join("");
|
|
40
|
-
}
|
|
41
|
-
var r = parseInt(hexColor.slice(0, 2), 16);
|
|
42
|
-
var g = parseInt(hexColor.slice(2, 4), 16);
|
|
43
|
-
var b = parseInt(hexColor.slice(4, 6), 16);
|
|
44
|
-
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
45
|
-
}
|
|
46
|
-
return color; // Return unchanged if unable to parse
|
|
47
|
-
};
|
|
48
|
-
exports.colorToRgba = colorToRgba;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateNumbers = void 0;
|
|
4
|
-
var padWithZero_1 = require("./padWithZero");
|
|
5
|
-
var generateNumbers = function (max, options) {
|
|
6
|
-
var _a;
|
|
7
|
-
var numbers = [];
|
|
8
|
-
if (options.padWithZero) {
|
|
9
|
-
for (var i = 0; i <= max; i++) {
|
|
10
|
-
numbers.push((0, padWithZero_1.padWithZero)(i));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
for (var i = 0; i <= max; i++) {
|
|
15
|
-
numbers.push(String(i));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
if (((_a = options.repeatNTimes) !== null && _a !== void 0 ? _a : 1) > 1) {
|
|
19
|
-
numbers = Array(options.repeatNTimes).fill(numbers).flat();
|
|
20
|
-
}
|
|
21
|
-
if (options.disableInfiniteScroll) {
|
|
22
|
-
numbers.push.apply(numbers, Array(options.padWithNItems).fill(""));
|
|
23
|
-
numbers.unshift.apply(numbers, Array(options.padWithNItems).fill(""));
|
|
24
|
-
}
|
|
25
|
-
return numbers;
|
|
26
|
-
};
|
|
27
|
-
exports.generateNumbers = generateNumbers;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const padWithZero: (value: number) => string;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.padWithZero = void 0;
|
|
4
|
-
var padWithZero = function (value) {
|
|
5
|
-
if (value < 10) {
|
|
6
|
-
return "0" + value;
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
return String(value);
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
exports.padWithZero = padWithZero;
|