react-native-timer-picker 1.2.0 → 1.2.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 +9 -5
- package/dist/components/TimerPicker/DurationScroll.d.ts +10 -2
- package/dist/components/TimerPicker/DurationScroll.js +55 -23
- package/dist/components/TimerPicker/index.d.ts +13 -1
- package/dist/components/TimerPicker/index.js +29 -6
- package/dist/components/index.d.ts +5 -1
- package/dist/components/index.js +8 -4
- package/dist/index.d.ts +1 -1
- package/dist/utils/getScrollIndex.d.ts +6 -0
- package/dist/utils/getScrollIndex.js +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -377,12 +377,12 @@ The following custom styles can be supplied to re-style the component in any way
|
|
|
377
377
|
|
|
378
378
|
## Methods 🔄
|
|
379
379
|
|
|
380
|
-
###
|
|
380
|
+
### TimerPicker
|
|
381
381
|
|
|
382
|
-
The library exposes a
|
|
382
|
+
The library exposes a TimerPickerRef type, which can be used to type your ref to the picker:
|
|
383
383
|
|
|
384
384
|
```javascript
|
|
385
|
-
const
|
|
385
|
+
const timerPickerRef = useRef<TimerPickerRef>(null);
|
|
386
386
|
```
|
|
387
387
|
|
|
388
388
|
It has the following available methods:
|
|
@@ -390,15 +390,19 @@ It has the following available methods:
|
|
|
390
390
|
`reset` - imperative method to reset the selected duration to their initial values.
|
|
391
391
|
|
|
392
392
|
```javascript
|
|
393
|
-
|
|
393
|
+
timerPickerRef.current.reset(options?: { animated: boolean });
|
|
394
394
|
```
|
|
395
395
|
|
|
396
396
|
`setValue` - imperative method to set the selected duration to a particular value
|
|
397
397
|
|
|
398
398
|
```javascript
|
|
399
|
-
|
|
399
|
+
timerPickerRef.current.setValue({ hours: number, minutes: number, seconds: number }, options?: { animated: boolean });
|
|
400
400
|
```
|
|
401
401
|
|
|
402
|
+
### TimerPickerModal
|
|
403
|
+
|
|
404
|
+
An identical ref is also exposed for the TimerPickerModal component.
|
|
405
|
+
|
|
402
406
|
## License 📝
|
|
403
407
|
|
|
404
408
|
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { generateStyles } from "./TimerPicker.styles";
|
|
4
|
+
export interface DurationScrollRef {
|
|
5
|
+
reset: (options?: {
|
|
6
|
+
animated?: boolean;
|
|
7
|
+
}) => void;
|
|
8
|
+
setValue: (value: number, options?: {
|
|
9
|
+
animated?: boolean;
|
|
10
|
+
}) => void;
|
|
11
|
+
}
|
|
4
12
|
type LinearGradientPoint = {
|
|
5
13
|
x: number;
|
|
6
14
|
y: number;
|
|
@@ -18,7 +26,7 @@ export type LimitType = {
|
|
|
18
26
|
interface DurationScrollProps {
|
|
19
27
|
numberOfItems: number;
|
|
20
28
|
label?: string | React.ReactElement;
|
|
21
|
-
|
|
29
|
+
initialValue?: number;
|
|
22
30
|
onDurationChange: (duration: number) => void;
|
|
23
31
|
padNumbersWithZero?: boolean;
|
|
24
32
|
disableInfiniteScroll?: boolean;
|
|
@@ -29,5 +37,5 @@ interface DurationScrollProps {
|
|
|
29
37
|
testID?: string;
|
|
30
38
|
styles: ReturnType<typeof generateStyles>;
|
|
31
39
|
}
|
|
32
|
-
declare const _default: React.MemoExoticComponent<
|
|
40
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<DurationScrollProps & React.RefAttributes<DurationScrollRef>>>;
|
|
33
41
|
export default _default;
|
|
@@ -38,11 +38,12 @@ var react_native_1 = require("react-native");
|
|
|
38
38
|
var generateNumbers_1 = require("../../utils/generateNumbers");
|
|
39
39
|
var colorToRgba_1 = require("../../utils/colorToRgba");
|
|
40
40
|
var getAdjustedLimit_1 = require("../../utils/getAdjustedLimit");
|
|
41
|
+
var getScrollIndex_1 = require("../../utils/getScrollIndex");
|
|
41
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
43
|
var KEY_EXTRACTOR = function (_, index) { return index.toString(); };
|
|
43
|
-
var DurationScroll = function (_a) {
|
|
44
|
+
var DurationScroll = (0, react_1.forwardRef)(function (_a, ref) {
|
|
44
45
|
var _b, _c, _d, _e;
|
|
45
|
-
var numberOfItems = _a.numberOfItems, label = _a.label, _f = _a.
|
|
46
|
+
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, LinearGradient = _a.LinearGradient, testID = _a.testID, styles = _a.styles;
|
|
46
47
|
var flatListRef = (0, react_1.useRef)(null);
|
|
47
48
|
var data = (0, generateNumbers_1.generateNumbers)(numberOfItems, {
|
|
48
49
|
padWithZero: padNumbersWithZero,
|
|
@@ -52,20 +53,47 @@ var DurationScroll = function (_a) {
|
|
|
52
53
|
});
|
|
53
54
|
var numberOfItemsToShow = 1 + padWithNItems * 2;
|
|
54
55
|
var adjustedLimited = (0, getAdjustedLimit_1.getAdjustedLimit)(limit, numberOfItems);
|
|
56
|
+
var initialScrollIndex = (0, getScrollIndex_1.getScrollIndex)({
|
|
57
|
+
value: initialValue,
|
|
58
|
+
numberOfItems: numberOfItems,
|
|
59
|
+
padWithNItems: padWithNItems,
|
|
60
|
+
disableInfiniteScroll: disableInfiniteScroll,
|
|
61
|
+
});
|
|
62
|
+
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
63
|
+
reset: function (options) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
(_a = flatListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex({
|
|
66
|
+
animated: (_b = options === null || options === void 0 ? void 0 : options.animated) !== null && _b !== void 0 ? _b : false,
|
|
67
|
+
index: initialScrollIndex,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
setValue: function (value, options) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
(_a = flatListRef.current) === null || _a === void 0 ? void 0 : _a.scrollToIndex({
|
|
73
|
+
animated: (_b = options === null || options === void 0 ? void 0 : options.animated) !== null && _b !== void 0 ? _b : false,
|
|
74
|
+
index: (0, getScrollIndex_1.getScrollIndex)({
|
|
75
|
+
value: value,
|
|
76
|
+
numberOfItems: numberOfItems,
|
|
77
|
+
padWithNItems: padWithNItems,
|
|
78
|
+
disableInfiniteScroll: disableInfiniteScroll,
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
}); });
|
|
55
83
|
var renderItem = (0, react_1.useCallback)(function (_a) {
|
|
56
84
|
var item = _a.item;
|
|
57
85
|
var intItem = parseInt(item);
|
|
58
86
|
return (<react_native_1.View key={item} style={styles.pickerItemContainer} testID="picker-item">
|
|
59
|
-
|
|
87
|
+
<react_native_1.Text style={[
|
|
60
88
|
styles.pickerItem,
|
|
61
89
|
intItem > adjustedLimited.max ||
|
|
62
90
|
intItem < adjustedLimited.min
|
|
63
91
|
? styles.disabledPickerItem
|
|
64
92
|
: {},
|
|
65
93
|
]}>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
94
|
+
{item}
|
|
95
|
+
</react_native_1.Text>
|
|
96
|
+
</react_native_1.View>);
|
|
69
97
|
}, [
|
|
70
98
|
adjustedLimited.max,
|
|
71
99
|
adjustedLimited.min,
|
|
@@ -77,7 +105,9 @@ var DurationScroll = function (_a) {
|
|
|
77
105
|
var _a, _b;
|
|
78
106
|
var newIndex = Math.round(e.nativeEvent.contentOffset.y /
|
|
79
107
|
styles.pickerItemContainer.height);
|
|
80
|
-
var newDuration = (disableInfiniteScroll
|
|
108
|
+
var newDuration = (disableInfiniteScroll
|
|
109
|
+
? newIndex
|
|
110
|
+
: newIndex + padWithNItems) %
|
|
81
111
|
(numberOfItems + 1);
|
|
82
112
|
// check limits
|
|
83
113
|
if (newDuration > adjustedLimited.max) {
|
|
@@ -148,33 +178,35 @@ var DurationScroll = function (_a) {
|
|
|
148
178
|
height: styles.pickerItemContainer.height * numberOfItemsToShow,
|
|
149
179
|
overflow: "hidden",
|
|
150
180
|
}}>
|
|
151
|
-
|
|
152
|
-
numberOfItems +
|
|
153
|
-
(disableInfiniteScroll ? padWithNItems : 0) -
|
|
154
|
-
(padWithNItems - 1)} windowSize={numberOfItemsToShow} renderItem={renderItem} keyExtractor={KEY_EXTRACTOR} showsVerticalScrollIndicator={false} decelerationRate="fast" scrollEventThrottle={16} snapToAlignment="start"
|
|
181
|
+
<react_native_1.FlatList ref={flatListRef} data={data} getItemLayout={getItemLayout} initialScrollIndex={initialScrollIndex} windowSize={numberOfItemsToShow} renderItem={renderItem} keyExtractor={KEY_EXTRACTOR} showsVerticalScrollIndicator={false} decelerationRate="fast" scrollEventThrottle={16} snapToAlignment="start"
|
|
155
182
|
// used in place of snapToOffset due to bug on Android
|
|
156
183
|
snapToOffsets={__spreadArray([], Array(data.length), true).map(function (_, i) { return i * styles.pickerItemContainer.height; })} viewabilityConfigCallbackPairs={!disableInfiniteScroll
|
|
157
184
|
? viewabilityConfigCallbackPairs === null || viewabilityConfigCallbackPairs === void 0 ? void 0 : viewabilityConfigCallbackPairs.current
|
|
158
185
|
: undefined} onMomentumScrollEnd={onMomentumScrollEnd} testID="duration-scroll-flatlist"/>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
186
|
+
<react_native_1.View style={styles.pickerLabelContainer}>
|
|
187
|
+
{typeof label === "string" ? (<react_native_1.Text style={styles.pickerLabel}>{label}</react_native_1.Text>) : (label !== null && label !== void 0 ? label : null)}
|
|
188
|
+
</react_native_1.View>
|
|
189
|
+
{LinearGradient ? (<>
|
|
190
|
+
<LinearGradient colors={[
|
|
164
191
|
(_b = styles.pickerContainer.backgroundColor) !== null && _b !== void 0 ? _b : "white",
|
|
165
192
|
(0, colorToRgba_1.colorToRgba)({
|
|
166
|
-
color: (_c = styles.pickerContainer
|
|
193
|
+
color: (_c = styles.pickerContainer
|
|
194
|
+
.backgroundColor) !== null && _c !== void 0 ? _c : "white",
|
|
167
195
|
opacity: 0,
|
|
168
196
|
}),
|
|
169
197
|
]} start={{ x: 1, y: 0.3 }} end={{ x: 1, y: 1 }} {...pickerGradientOverlayProps} style={[styles.pickerGradientOverlay, { top: 0 }]}/>
|
|
170
|
-
|
|
198
|
+
<LinearGradient colors={[
|
|
171
199
|
(0, colorToRgba_1.colorToRgba)({
|
|
172
|
-
color: (_d = styles.pickerContainer
|
|
200
|
+
color: (_d = styles.pickerContainer
|
|
201
|
+
.backgroundColor) !== null && _d !== void 0 ? _d : "white",
|
|
173
202
|
opacity: 0,
|
|
174
203
|
}),
|
|
175
204
|
(_e = styles.pickerContainer.backgroundColor) !== null && _e !== void 0 ? _e : "white",
|
|
176
|
-
]} start={{ x: 1, y: 0 }} end={{ x: 1, y: 0.7 }} {...pickerGradientOverlayProps} style={[
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
205
|
+
]} start={{ x: 1, y: 0 }} end={{ x: 1, y: 0.7 }} {...pickerGradientOverlayProps} style={[
|
|
206
|
+
styles.pickerGradientOverlay,
|
|
207
|
+
{ bottom: -1 },
|
|
208
|
+
]}/>
|
|
209
|
+
</>) : null}
|
|
210
|
+
</react_native_1.View>);
|
|
211
|
+
});
|
|
180
212
|
exports.default = react_1.default.memo(DurationScroll);
|
|
@@ -3,6 +3,18 @@ import { View } from "react-native";
|
|
|
3
3
|
import { LimitType } from "./DurationScroll";
|
|
4
4
|
import { CustomTimerPickerStyles } from "./TimerPicker.styles";
|
|
5
5
|
import { LinearGradientProps } from "./DurationScroll";
|
|
6
|
+
export interface TimerPickerRef {
|
|
7
|
+
reset: (options?: {
|
|
8
|
+
animated?: boolean;
|
|
9
|
+
}) => void;
|
|
10
|
+
setValue: (value: {
|
|
11
|
+
hours: number;
|
|
12
|
+
minutes: number;
|
|
13
|
+
seconds: number;
|
|
14
|
+
}, options?: {
|
|
15
|
+
animated?: boolean;
|
|
16
|
+
}) => void;
|
|
17
|
+
}
|
|
6
18
|
export interface TimerPickerProps {
|
|
7
19
|
onDurationChange?: (duration: {
|
|
8
20
|
hours: number;
|
|
@@ -28,5 +40,5 @@ export interface TimerPickerProps {
|
|
|
28
40
|
pickerGradientOverlayProps?: LinearGradientProps;
|
|
29
41
|
styles?: CustomTimerPickerStyles;
|
|
30
42
|
}
|
|
31
|
-
declare const _default: React.MemoExoticComponent<
|
|
43
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<TimerPickerProps & React.RefAttributes<TimerPickerRef>>>;
|
|
32
44
|
export default _default;
|
|
@@ -30,7 +30,7 @@ var react_1 = __importStar(require("react"));
|
|
|
30
30
|
var react_native_1 = require("react-native");
|
|
31
31
|
var DurationScroll_1 = __importDefault(require("./DurationScroll"));
|
|
32
32
|
var TimerPicker_styles_1 = require("./TimerPicker.styles");
|
|
33
|
-
var TimerPicker = function (_a) {
|
|
33
|
+
var TimerPicker = (0, react_1.forwardRef)(function (_a, ref) {
|
|
34
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, customStyles = _a.styles;
|
|
35
35
|
var checkedPadWithNItems = padWithNItems >= 0 ? Math.round(padWithNItems) : 0;
|
|
36
36
|
var styles = (0, react_1.useMemo)(function () {
|
|
@@ -49,10 +49,33 @@ var TimerPicker = function (_a) {
|
|
|
49
49
|
});
|
|
50
50
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
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
|
+
}); });
|
|
52
75
|
return (<react_native_1.View {...pickerContainerProps} style={styles.pickerContainer} testID="timer-picker">
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
76
|
+
{!hideHours ? (<DurationScroll_1.default ref={hoursDurationScrollRef} numberOfItems={23} label={hourLabel} initialValue={initialHours} onDurationChange={setSelectedHours} pickerGradientOverlayProps={pickerGradientOverlayProps} 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} 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} disableInfiniteScroll={disableInfiniteScroll} padWithNItems={checkedPadWithNItems} limit={secondLimit} LinearGradient={LinearGradient} styles={styles} testID="duration-scroll-second"/>) : null}
|
|
79
|
+
</react_native_1.View>);
|
|
80
|
+
});
|
|
58
81
|
exports.default = react_1.default.memo(TimerPicker);
|
|
@@ -4,11 +4,15 @@ import { TimerPickerProps } from "./TimerPicker";
|
|
|
4
4
|
import Modal from "./Modal";
|
|
5
5
|
import { CustomTimerPickerModalStyles } from "./TimerPickerModal.styles";
|
|
6
6
|
export interface TimerPickerModalRef {
|
|
7
|
-
reset: (
|
|
7
|
+
reset: (options?: {
|
|
8
|
+
animated?: boolean;
|
|
9
|
+
}) => void;
|
|
8
10
|
setValue: (value: {
|
|
9
11
|
hours: number;
|
|
10
12
|
minutes: number;
|
|
11
13
|
seconds: number;
|
|
14
|
+
}, options?: {
|
|
15
|
+
animated?: boolean;
|
|
12
16
|
}) => void;
|
|
13
17
|
}
|
|
14
18
|
export interface TimerPickerModalProps extends TimerPickerProps {
|
package/dist/components/index.js
CHANGED
|
@@ -66,8 +66,10 @@ var TimerPickerModal = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
66
66
|
setSelectedDuration(duration);
|
|
67
67
|
onDurationChange === null || onDurationChange === void 0 ? void 0 : onDurationChange(duration);
|
|
68
68
|
}, [onDurationChange]);
|
|
69
|
+
var timerPickerRef = (0, react_1.useRef)(null);
|
|
69
70
|
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
70
|
-
reset: function () {
|
|
71
|
+
reset: function (options) {
|
|
72
|
+
var _a;
|
|
71
73
|
var initialDuration = {
|
|
72
74
|
hours: initialHours,
|
|
73
75
|
minutes: initialMinutes,
|
|
@@ -75,11 +77,13 @@ var TimerPickerModal = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
75
77
|
};
|
|
76
78
|
setSelectedDuration(initialDuration);
|
|
77
79
|
setConfirmedDuration(initialDuration);
|
|
78
|
-
|
|
80
|
+
(_a = timerPickerRef.current) === null || _a === void 0 ? void 0 : _a.reset(options);
|
|
79
81
|
},
|
|
80
|
-
setValue: function (value) {
|
|
82
|
+
setValue: function (value, options) {
|
|
83
|
+
var _a;
|
|
81
84
|
setSelectedDuration(value);
|
|
82
85
|
setConfirmedDuration(value);
|
|
86
|
+
(_a = timerPickerRef.current) === null || _a === void 0 ? void 0 : _a.setValue(value, options);
|
|
83
87
|
},
|
|
84
88
|
}); });
|
|
85
89
|
return (<Modal_1.default isVisible={visible} onOverlayPress={closeOnOverlayPress ? hideModal : undefined} {...modalProps} testID="timer-picker-modal">
|
|
@@ -88,7 +92,7 @@ var TimerPickerModal = (0, react_1.forwardRef)(function (_a, ref) {
|
|
|
88
92
|
{modalTitle ? (<react_native_1.Text {...modalTitleProps} style={styles.modalTitle}>
|
|
89
93
|
{modalTitle}
|
|
90
94
|
</react_native_1.Text>) : null}
|
|
91
|
-
<TimerPicker_1.default 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} styles={customStyles}/>
|
|
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} styles={customStyles}/>
|
|
92
96
|
<react_native_1.View {...buttonContainerProps} style={styles.buttonContainer}>
|
|
93
97
|
{!hideCancelButton ? (<react_native_1.TouchableOpacity onPress={cancel}>
|
|
94
98
|
<react_native_1.Text style={[
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as TimerPickerModal, TimerPickerModalProps, TimerPickerModalRef, } from "./components";
|
|
2
|
-
export { default as TimerPicker, TimerPickerProps, } from "./components/TimerPicker";
|
|
2
|
+
export { default as TimerPicker, TimerPickerProps, TimerPickerRef, } from "./components/TimerPicker";
|
|
3
3
|
export { CustomTimerPickerModalStyles } from "./components/TimerPickerModal.styles";
|
|
4
4
|
export { CustomTimerPickerStyles } from "./components/TimerPicker/TimerPicker.styles";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getScrollIndex = void 0;
|
|
4
|
+
var getScrollIndex = function (variables) {
|
|
5
|
+
var value = variables.value, numberOfItems = variables.numberOfItems, padWithNItems = variables.padWithNItems, disableInfiniteScroll = variables.disableInfiniteScroll;
|
|
6
|
+
return (((value + numberOfItems) % (numberOfItems * 3)) +
|
|
7
|
+
(disableInfiniteScroll ? padWithNItems : 0) -
|
|
8
|
+
(padWithNItems - 1));
|
|
9
|
+
};
|
|
10
|
+
exports.getScrollIndex = getScrollIndex;
|