react-native-timer-picker 1.2.7 → 1.2.9
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/commonjs/components/Modal/Modal.styles.js +32 -0
- package/dist/commonjs/components/Modal/Modal.styles.js.map +1 -0
- package/dist/commonjs/components/Modal/index.js +108 -0
- package/dist/commonjs/components/Modal/index.js.map +1 -0
- package/dist/commonjs/components/TimerPicker/DurationScroll.js +210 -0
- package/dist/commonjs/components/TimerPicker/DurationScroll.js.map +1 -0
- package/dist/commonjs/components/TimerPicker/TimerPicker.styles.js +67 -0
- package/dist/commonjs/components/TimerPicker/TimerPicker.styles.js.map +1 -0
- package/dist/commonjs/components/TimerPicker/index.js +130 -0
- package/dist/commonjs/components/TimerPicker/index.js.map +1 -0
- package/dist/commonjs/components/TimerPickerModal.styles.js +69 -0
- package/dist/commonjs/components/TimerPickerModal.styles.js.map +1 -0
- package/dist/commonjs/components/index.js +156 -0
- package/dist/commonjs/components/index.js.map +1 -0
- package/dist/commonjs/index.js +21 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/tests/DurationScroll.test.js +56 -0
- package/dist/commonjs/tests/DurationScroll.test.js.map +1 -0
- package/dist/commonjs/tests/Modal.test.js +40 -0
- package/dist/commonjs/tests/Modal.test.js.map +1 -0
- package/dist/commonjs/tests/TimerPicker.test.js +37 -0
- package/dist/commonjs/tests/TimerPicker.test.js.map +1 -0
- package/dist/commonjs/tests/TimerPickerModal.test.js +73 -0
- package/dist/commonjs/tests/TimerPickerModal.test.js.map +1 -0
- package/dist/commonjs/utils/colorToRgba.js +51 -0
- package/dist/commonjs/utils/colorToRgba.js.map +1 -0
- package/dist/commonjs/utils/generateNumbers.js +32 -0
- package/dist/commonjs/utils/generateNumbers.js.map +1 -0
- package/dist/commonjs/utils/getAdjustedLimit.js +32 -0
- package/dist/commonjs/utils/getAdjustedLimit.js.map +1 -0
- package/dist/commonjs/utils/getScrollIndex.js +17 -0
- package/dist/commonjs/utils/getScrollIndex.js.map +1 -0
- package/dist/commonjs/utils/padWithZero.js +15 -0
- package/dist/commonjs/utils/padWithZero.js.map +1 -0
- package/dist/module/components/Modal/Modal.styles.js +26 -0
- package/dist/module/components/Modal/Modal.styles.js.map +1 -0
- package/dist/module/components/Modal/index.js +100 -0
- package/dist/module/components/Modal/index.js.map +1 -0
- package/dist/module/components/TimerPicker/DurationScroll.js +202 -0
- package/dist/module/components/TimerPicker/DurationScroll.js.map +1 -0
- package/dist/module/components/TimerPicker/TimerPicker.styles.js +59 -0
- package/dist/module/components/TimerPicker/TimerPicker.styles.js.map +1 -0
- package/dist/module/components/TimerPicker/index.js +121 -0
- package/dist/module/components/TimerPicker/index.js.map +1 -0
- package/dist/module/components/TimerPickerModal.styles.js +61 -0
- package/dist/module/components/TimerPickerModal.styles.js.map +1 -0
- package/dist/module/components/index.js +147 -0
- package/dist/module/components/index.js.map +1 -0
- package/dist/module/index.js +3 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/tests/DurationScroll.test.js +53 -0
- package/dist/module/tests/DurationScroll.test.js.map +1 -0
- package/dist/module/tests/Modal.test.js +37 -0
- package/dist/module/tests/Modal.test.js.map +1 -0
- package/dist/module/tests/TimerPicker.test.js +34 -0
- package/dist/module/tests/TimerPicker.test.js.map +1 -0
- package/dist/module/tests/TimerPickerModal.test.js +70 -0
- package/dist/module/tests/TimerPickerModal.test.js.map +1 -0
- package/dist/module/utils/colorToRgba.js +44 -0
- package/dist/module/utils/colorToRgba.js.map +1 -0
- package/dist/module/utils/generateNumbers.js +25 -0
- package/dist/module/utils/generateNumbers.js.map +1 -0
- package/dist/module/utils/getAdjustedLimit.js +25 -0
- package/dist/module/utils/getAdjustedLimit.js.map +1 -0
- package/dist/module/utils/getScrollIndex.js +10 -0
- package/dist/module/utils/getScrollIndex.js.map +1 -0
- package/dist/module/utils/padWithZero.js +8 -0
- package/dist/module/utils/padWithZero.js.map +1 -0
- package/dist/typescript/index.d.ts +4 -0
- package/dist/{utils → typescript/utils}/colorToRgba.d.ts +1 -1
- package/dist/{utils → typescript/utils}/getScrollIndex.d.ts +1 -1
- package/package.json +29 -12
- package/{dist/components/Modal/Modal.styles.js → src/components/Modal/Modal.styles.ts} +4 -6
- package/src/components/Modal/index.tsx +134 -0
- package/src/components/TimerPicker/DurationScroll.tsx +337 -0
- package/src/components/TimerPicker/TimerPicker.styles.ts +87 -0
- package/src/components/TimerPicker/index.tsx +216 -0
- package/src/components/TimerPickerModal.styles.ts +87 -0
- package/src/components/index.tsx +243 -0
- package/src/index.ts +14 -0
- package/src/tests/DurationScroll.test.tsx +57 -0
- package/src/tests/Modal.test.tsx +34 -0
- package/src/tests/TimerPicker.test.tsx +27 -0
- package/src/tests/TimerPickerModal.test.tsx +70 -0
- package/{dist/utils/colorToRgba.js → src/utils/colorToRgba.ts} +18 -17
- package/src/utils/generateNumbers.ts +34 -0
- package/{dist/utils/getAdjustedLimit.js → src/utils/getAdjustedLimit.ts} +14 -7
- package/src/utils/getScrollIndex.ts +15 -0
- package/src/utils/padWithZero.ts +7 -0
- package/dist/components/Modal/index.js +0 -109
- package/dist/components/TimerPicker/DurationScroll.js +0 -211
- package/dist/components/TimerPicker/TimerPicker.styles.js +0 -41
- package/dist/components/TimerPicker/index.js +0 -81
- package/dist/components/TimerPickerModal.styles.js +0 -37
- package/dist/components/index.js +0 -118
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -10
- package/dist/utils/generateNumbers.js +0 -30
- package/dist/utils/getScrollIndex.js +0 -10
- package/dist/utils/padWithZero.js +0 -12
- /package/dist/{components → typescript/components}/Modal/Modal.styles.d.ts +0 -0
- /package/dist/{components → typescript/components}/Modal/index.d.ts +0 -0
- /package/dist/{components → typescript/components}/TimerPicker/DurationScroll.d.ts +0 -0
- /package/dist/{components → typescript/components}/TimerPicker/TimerPicker.styles.d.ts +0 -0
- /package/dist/{components → typescript/components}/TimerPicker/index.d.ts +0 -0
- /package/dist/{components → typescript/components}/TimerPickerModal.styles.d.ts +0 -0
- /package/dist/{components → typescript/components}/index.d.ts +0 -0
- /package/dist/{utils → typescript/utils}/generateNumbers.d.ts +0 -0
- /package/dist/{utils → typescript/utils}/getAdjustedLimit.d.ts +0 -0
- /package/dist/{utils → typescript/utils}/padWithZero.d.ts +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const getScrollIndex = (variables: {
|
|
2
|
+
value: number;
|
|
3
|
+
numberOfItems: number;
|
|
4
|
+
padWithNItems: number;
|
|
5
|
+
disableInfiniteScroll?: boolean;
|
|
6
|
+
}) => {
|
|
7
|
+
const { value, numberOfItems, padWithNItems, disableInfiniteScroll } =
|
|
8
|
+
variables;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
((value + numberOfItems) % (numberOfItems * 3)) +
|
|
12
|
+
(disableInfiniteScroll ? padWithNItems : 0) -
|
|
13
|
+
(padWithNItems - 1)
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -1,109 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Modal = void 0;
|
|
27
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
28
|
-
var react_1 = __importStar(require("react"));
|
|
29
|
-
var react_native_1 = require("react-native");
|
|
30
|
-
var Modal_styles_1 = require("./Modal.styles");
|
|
31
|
-
var Modal = function (_a) {
|
|
32
|
-
var children = _a.children, onOverlayPress = _a.onOverlayPress, onHide = _a.onHide, _b = _a.isVisible, isVisible = _b === void 0 ? false : _b, _c = _a.animationDuration, animationDuration = _c === void 0 ? 300 : _c, _d = _a.overlayOpacity, overlayOpacity = _d === void 0 ? 0.4 : _d, modalProps = _a.modalProps, contentStyle = _a.contentStyle, overlayStyle = _a.overlayStyle, testID = _a.testID;
|
|
33
|
-
var _e = (0, react_native_1.useWindowDimensions)(), screenWidth = _e.width, screenHeight = _e.height;
|
|
34
|
-
var isMounted = (0, react_1.useRef)(false);
|
|
35
|
-
var animatedOpacity = (0, react_1.useRef)(new react_native_1.Animated.Value(0));
|
|
36
|
-
(0, react_1.useEffect)(function () {
|
|
37
|
-
isMounted.current = true;
|
|
38
|
-
if (isVisible) {
|
|
39
|
-
show();
|
|
40
|
-
}
|
|
41
|
-
return function () {
|
|
42
|
-
isMounted.current = false;
|
|
43
|
-
};
|
|
44
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
45
|
-
}, []);
|
|
46
|
-
var backdropAnimatedStyle = {
|
|
47
|
-
opacity: animatedOpacity.current.interpolate({
|
|
48
|
-
inputRange: [0, 1],
|
|
49
|
-
outputRange: [0, overlayOpacity],
|
|
50
|
-
}),
|
|
51
|
-
};
|
|
52
|
-
var contentAnimatedStyle = {
|
|
53
|
-
transform: [
|
|
54
|
-
{
|
|
55
|
-
translateY: animatedOpacity.current.interpolate({
|
|
56
|
-
inputRange: [0, 1],
|
|
57
|
-
outputRange: [screenHeight, 0],
|
|
58
|
-
extrapolate: "clamp",
|
|
59
|
-
}),
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
};
|
|
63
|
-
var show = (0, react_1.useCallback)(function () {
|
|
64
|
-
react_native_1.Animated.timing(animatedOpacity.current, {
|
|
65
|
-
easing: react_native_1.Easing.inOut(react_native_1.Easing.quad),
|
|
66
|
-
// Using native driver in the modal makes the content flash
|
|
67
|
-
useNativeDriver: true,
|
|
68
|
-
duration: animationDuration,
|
|
69
|
-
toValue: 1,
|
|
70
|
-
}).start();
|
|
71
|
-
}, [animationDuration]);
|
|
72
|
-
var hide = (0, react_1.useCallback)(function () {
|
|
73
|
-
react_native_1.Animated.timing(animatedOpacity.current, {
|
|
74
|
-
easing: react_native_1.Easing.inOut(react_native_1.Easing.quad),
|
|
75
|
-
// Using native driver in the modal makes the content flash
|
|
76
|
-
useNativeDriver: true,
|
|
77
|
-
duration: animationDuration,
|
|
78
|
-
toValue: 0,
|
|
79
|
-
}).start(function () {
|
|
80
|
-
if (isMounted.current) {
|
|
81
|
-
onHide === null || onHide === void 0 ? void 0 : onHide();
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}, [animationDuration, onHide]);
|
|
85
|
-
(0, react_1.useEffect)(function () {
|
|
86
|
-
if (isVisible) {
|
|
87
|
-
show();
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
hide();
|
|
91
|
-
}
|
|
92
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
|
-
}, [isVisible]);
|
|
94
|
-
return (<react_native_1.Modal transparent animationType="fade" visible={isVisible} {...modalProps} testID={testID !== null && testID !== void 0 ? testID : "modal"}>
|
|
95
|
-
<react_native_1.TouchableWithoutFeedback onPress={onOverlayPress} testID="modal-backdrop">
|
|
96
|
-
<react_native_1.Animated.View style={[
|
|
97
|
-
Modal_styles_1.styles.backdrop,
|
|
98
|
-
backdropAnimatedStyle,
|
|
99
|
-
{ width: screenWidth, height: screenHeight },
|
|
100
|
-
overlayStyle,
|
|
101
|
-
]}/>
|
|
102
|
-
</react_native_1.TouchableWithoutFeedback>
|
|
103
|
-
<react_native_1.Animated.View style={[Modal_styles_1.styles.content, contentAnimatedStyle, contentStyle]} pointerEvents="box-none">
|
|
104
|
-
{children}
|
|
105
|
-
</react_native_1.Animated.View>
|
|
106
|
-
</react_native_1.Modal>);
|
|
107
|
-
};
|
|
108
|
-
exports.Modal = Modal;
|
|
109
|
-
exports.default = react_1.default.memo(exports.Modal);
|
|
@@ -1,211 +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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
26
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
-
if (ar || !(i in from)) {
|
|
28
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
-
ar[i] = from[i];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
var react_1 = __importStar(require("react"));
|
|
36
|
-
var react_native_1 = require("react-native");
|
|
37
|
-
var generateNumbers_1 = require("../../utils/generateNumbers");
|
|
38
|
-
var colorToRgba_1 = require("../../utils/colorToRgba");
|
|
39
|
-
var getAdjustedLimit_1 = require("../../utils/getAdjustedLimit");
|
|
40
|
-
var getScrollIndex_1 = require("../../utils/getScrollIndex");
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
-
var KEY_EXTRACTOR = function (_, index) { return index.toString(); };
|
|
43
|
-
var DurationScroll = (0, react_1.forwardRef)(function (_a, ref) {
|
|
44
|
-
var _b, _c, _d, _e;
|
|
45
|
-
var numberOfItems = _a.numberOfItems, label = _a.label, _f = _a.initialValue, initialValue = _f === void 0 ? 0 : _f, onDurationChange = _a.onDurationChange, _g = _a.padNumbersWithZero, padNumbersWithZero = _g === void 0 ? false : _g, _h = _a.disableInfiniteScroll, disableInfiniteScroll = _h === void 0 ? false : _h, limit = _a.limit, padWithNItems = _a.padWithNItems, pickerGradientOverlayProps = _a.pickerGradientOverlayProps, topPickerGradientOverlayProps = _a.topPickerGradientOverlayProps, bottomPickerGradientOverlayProps = _a.bottomPickerGradientOverlayProps, LinearGradient = _a.LinearGradient, testID = _a.testID, styles = _a.styles;
|
|
46
|
-
var flatListRef = (0, react_1.useRef)(null);
|
|
47
|
-
var data = (0, generateNumbers_1.generateNumbers)(numberOfItems, {
|
|
48
|
-
padWithZero: padNumbersWithZero,
|
|
49
|
-
repeatNTimes: 3,
|
|
50
|
-
disableInfiniteScroll: disableInfiniteScroll,
|
|
51
|
-
padWithNItems: padWithNItems,
|
|
52
|
-
});
|
|
53
|
-
var numberOfItemsToShow = 1 + padWithNItems * 2;
|
|
54
|
-
var adjustedLimited = (0, getAdjustedLimit_1.getAdjustedLimit)(limit, numberOfItems);
|
|
55
|
-
var initialScrollIndex = (0, getScrollIndex_1.getScrollIndex)({
|
|
56
|
-
value: initialValue,
|
|
57
|
-
numberOfItems: numberOfItems,
|
|
58
|
-
padWithNItems: padWithNItems,
|
|
59
|
-
disableInfiniteScroll: disableInfiniteScroll,
|
|
60
|
-
});
|
|
61
|
-
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
62
|
-
reset: function (options) {
|
|
63
|
-
var _a, _b;
|
|
64
|
-
(_a = flatListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex({
|
|
65
|
-
animated: (_b = options === null || options === void 0 ? void 0 : options.animated) !== null && _b !== void 0 ? _b : false,
|
|
66
|
-
index: initialScrollIndex,
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
setValue: function (value, options) {
|
|
70
|
-
var _a, _b;
|
|
71
|
-
(_a = flatListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex({
|
|
72
|
-
animated: (_b = options === null || options === void 0 ? void 0 : options.animated) !== null && _b !== void 0 ? _b : false,
|
|
73
|
-
index: (0, getScrollIndex_1.getScrollIndex)({
|
|
74
|
-
value: value,
|
|
75
|
-
numberOfItems: numberOfItems,
|
|
76
|
-
padWithNItems: padWithNItems,
|
|
77
|
-
disableInfiniteScroll: disableInfiniteScroll,
|
|
78
|
-
}),
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
|
-
}); });
|
|
82
|
-
var renderItem = (0, react_1.useCallback)(function (_a) {
|
|
83
|
-
var item = _a.item;
|
|
84
|
-
var intItem = parseInt(item);
|
|
85
|
-
return (<react_native_1.View key={item} style={styles.pickerItemContainer} testID="picker-item">
|
|
86
|
-
<react_native_1.Text style={[
|
|
87
|
-
styles.pickerItem,
|
|
88
|
-
intItem > adjustedLimited.max ||
|
|
89
|
-
intItem < adjustedLimited.min
|
|
90
|
-
? styles.disabledPickerItem
|
|
91
|
-
: {},
|
|
92
|
-
]}>
|
|
93
|
-
{item}
|
|
94
|
-
</react_native_1.Text>
|
|
95
|
-
</react_native_1.View>);
|
|
96
|
-
}, [
|
|
97
|
-
adjustedLimited.max,
|
|
98
|
-
adjustedLimited.min,
|
|
99
|
-
styles.disabledPickerItem,
|
|
100
|
-
styles.pickerItem,
|
|
101
|
-
styles.pickerItemContainer,
|
|
102
|
-
]);
|
|
103
|
-
var onMomentumScrollEnd = (0, react_1.useCallback)(function (e) {
|
|
104
|
-
var _a, _b;
|
|
105
|
-
var newIndex = Math.round(e.nativeEvent.contentOffset.y /
|
|
106
|
-
styles.pickerItemContainer.height);
|
|
107
|
-
var newDuration = (disableInfiniteScroll
|
|
108
|
-
? newIndex
|
|
109
|
-
: newIndex + padWithNItems) %
|
|
110
|
-
(numberOfItems + 1);
|
|
111
|
-
// check limits
|
|
112
|
-
if (newDuration > adjustedLimited.max) {
|
|
113
|
-
var targetScrollIndex = newIndex - (newDuration - adjustedLimited.max);
|
|
114
|
-
(_a = flatListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex({
|
|
115
|
-
animated: true,
|
|
116
|
-
index:
|
|
117
|
-
// guard against scrolling beyond end of list
|
|
118
|
-
targetScrollIndex >= 0
|
|
119
|
-
? targetScrollIndex
|
|
120
|
-
: adjustedLimited.max - 1,
|
|
121
|
-
}); // scroll down to max
|
|
122
|
-
newDuration = adjustedLimited.max;
|
|
123
|
-
}
|
|
124
|
-
else if (newDuration < adjustedLimited.min) {
|
|
125
|
-
var targetScrollIndex = newIndex + (adjustedLimited.min - newDuration);
|
|
126
|
-
(_b = flatListRef.current) === null || _b === void 0 ? void 0 : _b.scrollToIndex({
|
|
127
|
-
animated: true,
|
|
128
|
-
index:
|
|
129
|
-
// guard against scrolling beyond end of list
|
|
130
|
-
targetScrollIndex <= data.length - 1
|
|
131
|
-
? targetScrollIndex
|
|
132
|
-
: adjustedLimited.min,
|
|
133
|
-
}); // scroll up to min
|
|
134
|
-
newDuration = adjustedLimited.min;
|
|
135
|
-
}
|
|
136
|
-
onDurationChange(newDuration);
|
|
137
|
-
}, [
|
|
138
|
-
adjustedLimited.max,
|
|
139
|
-
adjustedLimited.min,
|
|
140
|
-
data.length,
|
|
141
|
-
disableInfiniteScroll,
|
|
142
|
-
numberOfItems,
|
|
143
|
-
onDurationChange,
|
|
144
|
-
padWithNItems,
|
|
145
|
-
styles.pickerItemContainer.height,
|
|
146
|
-
]);
|
|
147
|
-
var onViewableItemsChanged = (0, react_1.useCallback)(function (_a) {
|
|
148
|
-
var _b, _c, _d, _e;
|
|
149
|
-
var viewableItems = _a.viewableItems;
|
|
150
|
-
if (((_b = viewableItems[0]) === null || _b === void 0 ? void 0 : _b.index) &&
|
|
151
|
-
viewableItems[0].index < numberOfItems * 0.5) {
|
|
152
|
-
(_c = flatListRef.current) === null || _c === void 0 ? void 0 : _c.scrollToIndex({
|
|
153
|
-
animated: false,
|
|
154
|
-
index: viewableItems[0].index + numberOfItems,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
else if (((_d = viewableItems[0]) === null || _d === void 0 ? void 0 : _d.index) &&
|
|
158
|
-
viewableItems[0].index >= numberOfItems * 2.5) {
|
|
159
|
-
(_e = flatListRef.current) === null || _e === void 0 ? void 0 : _e.scrollToIndex({
|
|
160
|
-
animated: false,
|
|
161
|
-
index: viewableItems[0].index - numberOfItems,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}, [numberOfItems]);
|
|
165
|
-
var getItemLayout = (0, react_1.useCallback)(function (_, index) { return ({
|
|
166
|
-
length: styles.pickerItemContainer.height,
|
|
167
|
-
offset: styles.pickerItemContainer.height * index,
|
|
168
|
-
index: index,
|
|
169
|
-
}); }, [styles.pickerItemContainer.height]);
|
|
170
|
-
var viewabilityConfigCallbackPairs = (0, react_1.useRef)([
|
|
171
|
-
{
|
|
172
|
-
viewabilityConfig: { viewAreaCoveragePercentThreshold: 25 },
|
|
173
|
-
onViewableItemsChanged: onViewableItemsChanged,
|
|
174
|
-
},
|
|
175
|
-
]);
|
|
176
|
-
return (<react_native_1.View testID={testID} style={{
|
|
177
|
-
height: styles.pickerItemContainer.height * numberOfItemsToShow,
|
|
178
|
-
overflow: "hidden",
|
|
179
|
-
}}>
|
|
180
|
-
<react_native_1.FlatList ref={flatListRef} data={data} getItemLayout={getItemLayout} initialScrollIndex={initialScrollIndex} windowSize={numberOfItemsToShow} renderItem={renderItem} keyExtractor={KEY_EXTRACTOR} showsVerticalScrollIndicator={false} decelerationRate={0.9} scrollEventThrottle={16} snapToAlignment="start"
|
|
181
|
-
// used in place of snapToOffset due to bug on Android
|
|
182
|
-
snapToOffsets={__spreadArray([], Array(data.length), true).map(function (_, i) { return i * styles.pickerItemContainer.height; })} viewabilityConfigCallbackPairs={!disableInfiniteScroll
|
|
183
|
-
? viewabilityConfigCallbackPairs === null || viewabilityConfigCallbackPairs === void 0 ? void 0 : viewabilityConfigCallbackPairs.current
|
|
184
|
-
: undefined} onMomentumScrollEnd={onMomentumScrollEnd} testID="duration-scroll-flatlist"/>
|
|
185
|
-
<react_native_1.View style={styles.pickerLabelContainer} pointerEvents="none">
|
|
186
|
-
{typeof label === "string" ? (<react_native_1.Text style={styles.pickerLabel}>{label}</react_native_1.Text>) : (label !== null && label !== void 0 ? label : null)}
|
|
187
|
-
</react_native_1.View>
|
|
188
|
-
{LinearGradient ? (<>
|
|
189
|
-
<LinearGradient colors={[
|
|
190
|
-
(_b = styles.pickerContainer.backgroundColor) !== null && _b !== void 0 ? _b : "white",
|
|
191
|
-
(0, colorToRgba_1.colorToRgba)({
|
|
192
|
-
color: (_c = styles.pickerContainer
|
|
193
|
-
.backgroundColor) !== null && _c !== void 0 ? _c : "white",
|
|
194
|
-
opacity: 0,
|
|
195
|
-
}),
|
|
196
|
-
]} start={{ x: 1, y: 0.3 }} end={{ x: 1, y: 1 }} pointerEvents="none" {...pickerGradientOverlayProps} {...topPickerGradientOverlayProps} style={[styles.pickerGradientOverlay, { top: 0 }]}/>
|
|
197
|
-
<LinearGradient colors={[
|
|
198
|
-
(0, colorToRgba_1.colorToRgba)({
|
|
199
|
-
color: (_d = styles.pickerContainer
|
|
200
|
-
.backgroundColor) !== null && _d !== void 0 ? _d : "white",
|
|
201
|
-
opacity: 0,
|
|
202
|
-
}),
|
|
203
|
-
(_e = styles.pickerContainer.backgroundColor) !== null && _e !== void 0 ? _e : "white",
|
|
204
|
-
]} start={{ x: 1, y: 0 }} end={{ x: 1, y: 0.7 }} pointerEvents="none" {...pickerGradientOverlayProps} {...bottomPickerGradientOverlayProps} style={[
|
|
205
|
-
styles.pickerGradientOverlay,
|
|
206
|
-
{ bottom: -1 },
|
|
207
|
-
]}/>
|
|
208
|
-
</>) : null}
|
|
209
|
-
</react_native_1.View>);
|
|
210
|
-
});
|
|
211
|
-
exports.default = react_1.default.memo(DurationScroll);
|
|
@@ -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, options) {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
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(__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: (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.text), customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerLabel),
|
|
31
|
-
pickerItemContainer: __assign({ height: 50, justifyContent: "center", alignItems: "center", width: ((_e = (_d = customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItem) === null || _d === void 0 ? void 0 : _d.fontSize) !== null && _e !== void 0 ? _e : 25) * 3.6 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItemContainer),
|
|
32
|
-
pickerItem: __assign(__assign({ textAlignVertical: "center", fontSize: 25, color: (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.text), customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItem),
|
|
35
|
-
disabledPickerItem: __assign({ opacity: 0.2 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.disabledPickerItem),
|
|
36
|
-
pickerGradientOverlay: __assign({ position: "absolute", left: 0, right: 0, height: options.padWithNItems === 0
|
|
37
|
-
? "30%"
|
|
38
|
-
: ((_g = (_f = customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItemContainer) === null || _f === void 0 ? void 0 : _f.height) !== null && _g !== void 0 ? _g : 50) * 0.8 }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerGradientOverlay),
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
exports.generateStyles = generateStyles;
|
|
@@ -1,81 +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 = (0, react_1.forwardRef)(function (_a, ref) {
|
|
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, hourLimit = _a.hourLimit, minuteLimit = _a.minuteLimit, secondLimit = _a.secondLimit, _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, LinearGradient = _a.LinearGradient, pickerContainerProps = _a.pickerContainerProps, pickerGradientOverlayProps = _a.pickerGradientOverlayProps, topPickerGradientOverlayProps = _a.topPickerGradientOverlayProps, bottomPickerGradientOverlayProps = _a.bottomPickerGradientOverlayProps, customStyles = _a.styles;
|
|
35
|
-
var checkedPadWithNItems = padWithNItems >= 0 ? Math.round(padWithNItems) : 0;
|
|
36
|
-
var styles = (0, react_1.useMemo)(function () {
|
|
37
|
-
return (0, TimerPicker_styles_1.generateStyles)(customStyles, {
|
|
38
|
-
padWithNItems: checkedPadWithNItems,
|
|
39
|
-
});
|
|
40
|
-
}, [checkedPadWithNItems, customStyles]);
|
|
41
|
-
var _o = (0, react_1.useState)(initialHours), selectedHours = _o[0], setSelectedHours = _o[1];
|
|
42
|
-
var _p = (0, react_1.useState)(initialMinutes), selectedMinutes = _p[0], setSelectedMinutes = _p[1];
|
|
43
|
-
var _q = (0, react_1.useState)(initialSeconds), selectedSeconds = _q[0], setSelectedSeconds = _q[1];
|
|
44
|
-
(0, react_1.useEffect)(function () {
|
|
45
|
-
onDurationChange === null || onDurationChange === void 0 ? void 0 : onDurationChange({
|
|
46
|
-
hours: selectedHours,
|
|
47
|
-
minutes: selectedMinutes,
|
|
48
|
-
seconds: selectedSeconds,
|
|
49
|
-
});
|
|
50
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
-
}, [selectedHours, selectedMinutes, selectedSeconds]);
|
|
52
|
-
var hoursDurationScrollRef = (0, react_1.useRef)(null);
|
|
53
|
-
var minutesDurationScrollRef = (0, react_1.useRef)(null);
|
|
54
|
-
var secondsDurationScrollRef = (0, react_1.useRef)(null);
|
|
55
|
-
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
56
|
-
reset: function (options) {
|
|
57
|
-
var _a, _b, _c;
|
|
58
|
-
setSelectedHours(initialHours);
|
|
59
|
-
setSelectedMinutes(initialMinutes);
|
|
60
|
-
setSelectedSeconds(initialSeconds);
|
|
61
|
-
(_a = hoursDurationScrollRef.current) === null || _a === void 0 ? void 0 : _a.reset(options);
|
|
62
|
-
(_b = minutesDurationScrollRef.current) === null || _b === void 0 ? void 0 : _b.reset(options);
|
|
63
|
-
(_c = secondsDurationScrollRef.current) === null || _c === void 0 ? void 0 : _c.reset(options);
|
|
64
|
-
},
|
|
65
|
-
setValue: function (value, options) {
|
|
66
|
-
var _a, _b, _c;
|
|
67
|
-
setSelectedHours(value.hours);
|
|
68
|
-
setSelectedMinutes(value.minutes);
|
|
69
|
-
setSelectedSeconds(value.seconds);
|
|
70
|
-
(_a = hoursDurationScrollRef.current) === null || _a === void 0 ? void 0 : _a.setValue(value.hours, options);
|
|
71
|
-
(_b = minutesDurationScrollRef.current) === null || _b === void 0 ? void 0 : _b.setValue(value.minutes, options);
|
|
72
|
-
(_c = secondsDurationScrollRef.current) === null || _c === void 0 ? void 0 : _c.setValue(value.seconds, options);
|
|
73
|
-
},
|
|
74
|
-
}); });
|
|
75
|
-
return (<react_native_1.View {...pickerContainerProps} style={styles.pickerContainer} testID="timer-picker">
|
|
76
|
-
{!hideHours ? (<DurationScroll_1.default ref={hoursDurationScrollRef} numberOfItems={23} label={hourLabel} initialValue={initialHours} onDurationChange={setSelectedHours} pickerGradientOverlayProps={pickerGradientOverlayProps} topPickerGradientOverlayProps={topPickerGradientOverlayProps} bottomPickerGradientOverlayProps={bottomPickerGradientOverlayProps} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} limit={hourLimit} LinearGradient={LinearGradient} styles={styles} testID="duration-scroll-hour"/>) : null}
|
|
77
|
-
{!hideMinutes ? (<DurationScroll_1.default ref={minutesDurationScrollRef} numberOfItems={59} label={minuteLabel} initialValue={initialMinutes} onDurationChange={setSelectedMinutes} padNumbersWithZero pickerGradientOverlayProps={pickerGradientOverlayProps} topPickerGradientOverlayProps={topPickerGradientOverlayProps} bottomPickerGradientOverlayProps={bottomPickerGradientOverlayProps} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} limit={minuteLimit} LinearGradient={LinearGradient} styles={styles} testID="duration-scroll-minute"/>) : null}
|
|
78
|
-
{!hideSeconds ? (<DurationScroll_1.default ref={secondsDurationScrollRef} numberOfItems={59} label={secondLabel} initialValue={initialSeconds} onDurationChange={setSelectedSeconds} padNumbersWithZero pickerGradientOverlayProps={pickerGradientOverlayProps} topPickerGradientOverlayProps={topPickerGradientOverlayProps} bottomPickerGradientOverlayProps={bottomPickerGradientOverlayProps} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} limit={secondLimit} LinearGradient={LinearGradient} styles={styles} testID="duration-scroll-second"/>) : null}
|
|
79
|
-
</react_native_1.View>);
|
|
80
|
-
});
|
|
81
|
-
exports.default = react_1.default.memo(TimerPicker);
|
|
@@ -1,37 +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;
|
|
23
|
-
return react_native_1.StyleSheet.create({
|
|
24
|
-
container: __assign({ justifyContent: "center", alignItems: "center", overflow: "hidden" }, 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(__assign({ marginHorizontal: 12, paddingVertical: 10, paddingHorizontal: 20, borderWidth: 1, borderRadius: 10, fontSize: 16, overflow: "hidden" }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.text), customStyles === null || customStyles === void 0 ? void 0 : customStyles.button),
|
|
30
|
-
cancelButton: __assign(__assign({ borderColor: "gray", color: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? DARK_MODE_TEXT_COLOR : "gray", backgroundColor: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? "gray" : undefined }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.text), customStyles === null || customStyles === void 0 ? void 0 : customStyles.cancelButton),
|
|
31
|
-
confirmButton: __assign(__assign({ borderColor: "green", color: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? DARK_MODE_TEXT_COLOR : "green", backgroundColor: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? "green" : undefined }, customStyles === null || customStyles === void 0 ? void 0 : customStyles.text), customStyles === null || customStyles === void 0 ? void 0 : customStyles.confirmButton),
|
|
32
|
-
modalTitle: __assign(__assign({ fontSize: 24, fontWeight: "bold", marginBottom: 15, color: (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.text), customStyles === null || customStyles === void 0 ? void 0 : customStyles.modalTitle),
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
exports.generateStyles = generateStyles;
|
package/dist/components/index.js
DELETED
|
@@ -1,118 +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 = (0, react_1.forwardRef)(function (_a, ref) {
|
|
35
|
-
var visible = _a.visible, setIsVisible = _a.setIsVisible, onConfirm = _a.onConfirm, onCancel = _a.onCancel, onDurationChange = _a.onDurationChange, 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, hourLimit = _a.hourLimit, minuteLimit = _a.minuteLimit, secondLimit = _a.secondLimit, _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, LinearGradient = _a.LinearGradient, modalProps = _a.modalProps, containerProps = _a.containerProps, contentContainerProps = _a.contentContainerProps, pickerContainerProps = _a.pickerContainerProps, buttonContainerProps = _a.buttonContainerProps, buttonTouchableOpacityProps = _a.buttonTouchableOpacityProps, modalTitleProps = _a.modalTitleProps, pickerGradientOverlayProps = _a.pickerGradientOverlayProps, topPickerGradientOverlayProps = _a.topPickerGradientOverlayProps, bottomPickerGradientOverlayProps = _a.bottomPickerGradientOverlayProps, 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
|
-
setConfirmedDuration(selectedDuration);
|
|
57
|
-
onConfirm(selectedDuration);
|
|
58
|
-
};
|
|
59
|
-
var cancel = function () {
|
|
60
|
-
setIsVisible(false);
|
|
61
|
-
setSelectedDuration(confirmedDuration);
|
|
62
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
63
|
-
};
|
|
64
|
-
// wrapped in useCallback to avoid unnecessary re-renders of TimerPicker
|
|
65
|
-
var durationChange = (0, react_1.useCallback)(function (duration) {
|
|
66
|
-
setSelectedDuration(duration);
|
|
67
|
-
onDurationChange === null || onDurationChange === void 0 ? void 0 : onDurationChange(duration);
|
|
68
|
-
}, [onDurationChange]);
|
|
69
|
-
var timerPickerRef = (0, react_1.useRef)(null);
|
|
70
|
-
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
71
|
-
reset: function (options) {
|
|
72
|
-
var _a;
|
|
73
|
-
var initialDuration = {
|
|
74
|
-
hours: initialHours,
|
|
75
|
-
minutes: initialMinutes,
|
|
76
|
-
seconds: initialSeconds,
|
|
77
|
-
};
|
|
78
|
-
setSelectedDuration(initialDuration);
|
|
79
|
-
setConfirmedDuration(initialDuration);
|
|
80
|
-
(_a = timerPickerRef.current) === null || _a === void 0 ? void 0 : _a.reset(options);
|
|
81
|
-
},
|
|
82
|
-
setValue: function (value, options) {
|
|
83
|
-
var _a;
|
|
84
|
-
setSelectedDuration(value);
|
|
85
|
-
setConfirmedDuration(value);
|
|
86
|
-
(_a = timerPickerRef.current) === null || _a === void 0 ? void 0 : _a.setValue(value, options);
|
|
87
|
-
},
|
|
88
|
-
}); });
|
|
89
|
-
return (<Modal_1.default isVisible={visible} onOverlayPress={closeOnOverlayPress ? hideModal : undefined} {...modalProps} testID="timer-picker-modal">
|
|
90
|
-
<react_native_1.View {...containerProps} style={styles.container}>
|
|
91
|
-
<react_native_1.View {...contentContainerProps} style={styles.contentContainer}>
|
|
92
|
-
{modalTitle ? (<react_native_1.Text {...modalTitleProps} style={styles.modalTitle}>
|
|
93
|
-
{modalTitle}
|
|
94
|
-
</react_native_1.Text>) : null}
|
|
95
|
-
<TimerPicker_1.default ref={timerPickerRef} onDurationChange={durationChange} initialHours={confirmedDuration.hours} initialMinutes={confirmedDuration.minutes} initialSeconds={confirmedDuration.seconds} hideHours={hideHours} hideMinutes={hideMinutes} hideSeconds={hideSeconds} hourLimit={hourLimit} minuteLimit={minuteLimit} secondLimit={secondLimit} hourLabel={hourLabel} minuteLabel={minuteLabel} secondLabel={secondLabel} padWithNItems={padWithNItems} disableInfiniteScroll={disableInfiniteScroll} LinearGradient={LinearGradient} pickerContainerProps={pickerContainerProps} pickerGradientOverlayProps={pickerGradientOverlayProps} topPickerGradientOverlayProps={topPickerGradientOverlayProps} bottomPickerGradientOverlayProps={bottomPickerGradientOverlayProps} styles={customStyles}/>
|
|
96
|
-
<react_native_1.View {...buttonContainerProps} style={styles.buttonContainer}>
|
|
97
|
-
{!hideCancelButton ? (<react_native_1.TouchableOpacity onPress={cancel} {...buttonTouchableOpacityProps}>
|
|
98
|
-
<react_native_1.Text style={[
|
|
99
|
-
styles.button,
|
|
100
|
-
styles.cancelButton,
|
|
101
|
-
]}>
|
|
102
|
-
{cancelButtonText}
|
|
103
|
-
</react_native_1.Text>
|
|
104
|
-
</react_native_1.TouchableOpacity>) : null}
|
|
105
|
-
<react_native_1.TouchableOpacity onPress={confirm} {...buttonTouchableOpacityProps}>
|
|
106
|
-
<react_native_1.Text style={[
|
|
107
|
-
styles.button,
|
|
108
|
-
styles.confirmButton,
|
|
109
|
-
]}>
|
|
110
|
-
{confirmButtonText}
|
|
111
|
-
</react_native_1.Text>
|
|
112
|
-
</react_native_1.TouchableOpacity>
|
|
113
|
-
</react_native_1.View>
|
|
114
|
-
</react_native_1.View>
|
|
115
|
-
</react_native_1.View>
|
|
116
|
-
</Modal_1.default>);
|
|
117
|
-
});
|
|
118
|
-
exports.default = react_1.default.memo(TimerPickerModal);
|
package/dist/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { default as TimerPickerModal, TimerPickerModalProps, TimerPickerModalRef, } from "./components";
|
|
2
|
-
export { default as TimerPicker, TimerPickerProps, TimerPickerRef, } 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; } });
|