react-native-timer-picker 2.4.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -25
- package/package.json +143 -126
- package/dist/commonjs/components/DurationScroll/DurationScroll.js +0 -403
- package/dist/commonjs/components/DurationScroll/DurationScroll.js.map +0 -1
- package/dist/commonjs/components/DurationScroll/index.js +0 -27
- package/dist/commonjs/components/DurationScroll/index.js.map +0 -1
- package/dist/commonjs/components/DurationScroll/types.js +0 -6
- package/dist/commonjs/components/DurationScroll/types.js.map +0 -1
- package/dist/commonjs/components/Modal/Modal.js +0 -107
- package/dist/commonjs/components/Modal/Modal.js.map +0 -1
- package/dist/commonjs/components/Modal/index.js +0 -27
- package/dist/commonjs/components/Modal/index.js.map +0 -1
- package/dist/commonjs/components/Modal/styles.js +0 -25
- package/dist/commonjs/components/Modal/styles.js.map +0 -1
- package/dist/commonjs/components/Modal/types.js +0 -6
- package/dist/commonjs/components/Modal/types.js.map +0 -1
- package/dist/commonjs/components/PickerItem/PickerItem.js +0 -45
- package/dist/commonjs/components/PickerItem/PickerItem.js.map +0 -1
- package/dist/commonjs/components/PickerItem/index.js +0 -14
- package/dist/commonjs/components/PickerItem/index.js.map +0 -1
- package/dist/commonjs/components/TimerPicker/TimerPicker.js +0 -236
- package/dist/commonjs/components/TimerPicker/TimerPicker.js.map +0 -1
- package/dist/commonjs/components/TimerPicker/index.js +0 -39
- package/dist/commonjs/components/TimerPicker/index.js.map +0 -1
- package/dist/commonjs/components/TimerPicker/styles.js +0 -121
- package/dist/commonjs/components/TimerPicker/styles.js.map +0 -1
- package/dist/commonjs/components/TimerPicker/types.js +0 -6
- package/dist/commonjs/components/TimerPicker/types.js.map +0 -1
- package/dist/commonjs/components/TimerPickerModal/TimerPickerModal.js +0 -153
- package/dist/commonjs/components/TimerPickerModal/TimerPickerModal.js.map +0 -1
- package/dist/commonjs/components/TimerPickerModal/index.js +0 -39
- package/dist/commonjs/components/TimerPickerModal/index.js.map +0 -1
- package/dist/commonjs/components/TimerPickerModal/styles.js +0 -89
- package/dist/commonjs/components/TimerPickerModal/styles.js.map +0 -1
- package/dist/commonjs/components/TimerPickerModal/types.js +0 -6
- package/dist/commonjs/components/TimerPickerModal/types.js.map +0 -1
- package/dist/commonjs/index.js +0 -57
- package/dist/commonjs/index.js.map +0 -1
- package/dist/commonjs/tests/DurationScroll.test.js +0 -163
- package/dist/commonjs/tests/DurationScroll.test.js.map +0 -1
- package/dist/commonjs/tests/Modal.test.js +0 -119
- package/dist/commonjs/tests/Modal.test.js.map +0 -1
- package/dist/commonjs/tests/TimerPicker.test.js +0 -169
- package/dist/commonjs/tests/TimerPicker.test.js.map +0 -1
- package/dist/commonjs/tests/TimerPickerModal.test.js +0 -276
- package/dist/commonjs/tests/TimerPickerModal.test.js.map +0 -1
- package/dist/commonjs/tests/colorToRgba.test.js +0 -176
- package/dist/commonjs/tests/colorToRgba.test.js.map +0 -1
- package/dist/commonjs/tests/generateNumbers.test.js +0 -350
- package/dist/commonjs/tests/generateNumbers.test.js.map +0 -1
- package/dist/commonjs/tests/getAdjustedLimit.test.js +0 -324
- package/dist/commonjs/tests/getAdjustedLimit.test.js.map +0 -1
- package/dist/commonjs/tests/getDurationAndIndexFromScrollOffset.test.js +0 -424
- package/dist/commonjs/tests/getDurationAndIndexFromScrollOffset.test.js.map +0 -1
- package/dist/commonjs/tests/getInitialScrollIndex.test.js +0 -396
- package/dist/commonjs/tests/getInitialScrollIndex.test.js.map +0 -1
- package/dist/commonjs/tests/getSafeInitialValue.test.js +0 -497
- package/dist/commonjs/tests/getSafeInitialValue.test.js.map +0 -1
- package/dist/commonjs/tests/padNumber.test.js +0 -301
- package/dist/commonjs/tests/padNumber.test.js.map +0 -1
- package/dist/commonjs/utils/colorToRgba.js +0 -87
- package/dist/commonjs/utils/colorToRgba.js.map +0 -1
- package/dist/commonjs/utils/generateNumbers.js +0 -124
- package/dist/commonjs/utils/generateNumbers.js.map +0 -1
- package/dist/commonjs/utils/getAdjustedLimit.js +0 -58
- package/dist/commonjs/utils/getAdjustedLimit.js.map +0 -1
- package/dist/commonjs/utils/getDurationAndIndexFromScrollOffset.js +0 -62
- package/dist/commonjs/utils/getDurationAndIndexFromScrollOffset.js.map +0 -1
- package/dist/commonjs/utils/getInitialScrollIndex.js +0 -57
- package/dist/commonjs/utils/getInitialScrollIndex.js.map +0 -1
- package/dist/commonjs/utils/getSafeInitialValue.js +0 -41
- package/dist/commonjs/utils/getSafeInitialValue.js.map +0 -1
- package/dist/commonjs/utils/padNumber.js +0 -40
- package/dist/commonjs/utils/padNumber.js.map +0 -1
- package/dist/module/components/DurationScroll/DurationScroll.js +0 -395
- package/dist/module/components/DurationScroll/DurationScroll.js.map +0 -1
- package/dist/module/components/DurationScroll/index.js +0 -3
- package/dist/module/components/DurationScroll/index.js.map +0 -1
- package/dist/module/components/DurationScroll/types.js +0 -2
- package/dist/module/components/DurationScroll/types.js.map +0 -1
- package/dist/module/components/Modal/Modal.js +0 -99
- package/dist/module/components/Modal/Modal.js.map +0 -1
- package/dist/module/components/Modal/index.js +0 -3
- package/dist/module/components/Modal/index.js.map +0 -1
- package/dist/module/components/Modal/styles.js +0 -19
- package/dist/module/components/Modal/styles.js.map +0 -1
- package/dist/module/components/Modal/types.js +0 -2
- package/dist/module/components/Modal/types.js.map +0 -1
- package/dist/module/components/PickerItem/PickerItem.js +0 -38
- package/dist/module/components/PickerItem/PickerItem.js.map +0 -1
- package/dist/module/components/PickerItem/index.js +0 -2
- package/dist/module/components/PickerItem/index.js.map +0 -1
- package/dist/module/components/TimerPicker/TimerPicker.js +0 -228
- package/dist/module/components/TimerPicker/TimerPicker.js.map +0 -1
- package/dist/module/components/TimerPicker/index.js +0 -4
- package/dist/module/components/TimerPicker/index.js.map +0 -1
- package/dist/module/components/TimerPicker/styles.js +0 -114
- package/dist/module/components/TimerPicker/styles.js.map +0 -1
- package/dist/module/components/TimerPicker/types.js +0 -2
- package/dist/module/components/TimerPicker/types.js.map +0 -1
- package/dist/module/components/TimerPickerModal/TimerPickerModal.js +0 -145
- package/dist/module/components/TimerPickerModal/TimerPickerModal.js.map +0 -1
- package/dist/module/components/TimerPickerModal/index.js +0 -4
- package/dist/module/components/TimerPickerModal/index.js.map +0 -1
- package/dist/module/components/TimerPickerModal/styles.js +0 -82
- package/dist/module/components/TimerPickerModal/styles.js.map +0 -1
- package/dist/module/components/TimerPickerModal/types.js +0 -2
- package/dist/module/components/TimerPickerModal/types.js.map +0 -1
- package/dist/module/index.js +0 -3
- package/dist/module/index.js.map +0 -1
- package/dist/module/tests/DurationScroll.test.js +0 -160
- package/dist/module/tests/DurationScroll.test.js.map +0 -1
- package/dist/module/tests/Modal.test.js +0 -116
- package/dist/module/tests/Modal.test.js.map +0 -1
- package/dist/module/tests/TimerPicker.test.js +0 -166
- package/dist/module/tests/TimerPicker.test.js.map +0 -1
- package/dist/module/tests/TimerPickerModal.test.js +0 -273
- package/dist/module/tests/TimerPickerModal.test.js.map +0 -1
- package/dist/module/tests/colorToRgba.test.js +0 -174
- package/dist/module/tests/colorToRgba.test.js.map +0 -1
- package/dist/module/tests/generateNumbers.test.js +0 -348
- package/dist/module/tests/generateNumbers.test.js.map +0 -1
- package/dist/module/tests/getAdjustedLimit.test.js +0 -322
- package/dist/module/tests/getAdjustedLimit.test.js.map +0 -1
- package/dist/module/tests/getDurationAndIndexFromScrollOffset.test.js +0 -422
- package/dist/module/tests/getDurationAndIndexFromScrollOffset.test.js.map +0 -1
- package/dist/module/tests/getInitialScrollIndex.test.js +0 -394
- package/dist/module/tests/getInitialScrollIndex.test.js.map +0 -1
- package/dist/module/tests/getSafeInitialValue.test.js +0 -495
- package/dist/module/tests/getSafeInitialValue.test.js.map +0 -1
- package/dist/module/tests/padNumber.test.js +0 -299
- package/dist/module/tests/padNumber.test.js.map +0 -1
- package/dist/module/utils/colorToRgba.js +0 -80
- package/dist/module/utils/colorToRgba.js.map +0 -1
- package/dist/module/utils/generateNumbers.js +0 -117
- package/dist/module/utils/generateNumbers.js.map +0 -1
- package/dist/module/utils/getAdjustedLimit.js +0 -51
- package/dist/module/utils/getAdjustedLimit.js.map +0 -1
- package/dist/module/utils/getDurationAndIndexFromScrollOffset.js +0 -55
- package/dist/module/utils/getDurationAndIndexFromScrollOffset.js.map +0 -1
- package/dist/module/utils/getInitialScrollIndex.js +0 -50
- package/dist/module/utils/getInitialScrollIndex.js.map +0 -1
- package/dist/module/utils/getSafeInitialValue.js +0 -34
- package/dist/module/utils/getSafeInitialValue.js.map +0 -1
- package/dist/module/utils/padNumber.js +0 -33
- package/dist/module/utils/padNumber.js.map +0 -1
- package/dist/typescript/components/DurationScroll/DurationScroll.d.ts +0 -4
- package/dist/typescript/components/DurationScroll/index.d.ts +0 -2
- package/dist/typescript/components/DurationScroll/types.d.ts +0 -66
- package/dist/typescript/components/Modal/Modal.d.ts +0 -5
- package/dist/typescript/components/Modal/index.d.ts +0 -2
- package/dist/typescript/components/Modal/styles.d.ts +0 -17
- package/dist/typescript/components/Modal/types.d.ts +0 -15
- package/dist/typescript/components/PickerItem/PickerItem.d.ts +0 -14
- package/dist/typescript/components/PickerItem/index.d.ts +0 -1
- package/dist/typescript/components/TimerPicker/TimerPicker.d.ts +0 -4
- package/dist/typescript/components/TimerPicker/index.d.ts +0 -3
- package/dist/typescript/components/TimerPicker/styles.d.ts +0 -1451
- package/dist/typescript/components/TimerPicker/types.d.ts +0 -90
- package/dist/typescript/components/TimerPickerModal/TimerPickerModal.d.ts +0 -4
- package/dist/typescript/components/TimerPickerModal/index.d.ts +0 -3
- package/dist/typescript/components/TimerPickerModal/styles.d.ts +0 -947
- package/dist/typescript/components/TimerPickerModal/types.d.ts +0 -55
- package/dist/typescript/index.d.ts +0 -2
- package/dist/typescript/utils/colorToRgba.d.ts +0 -38
- package/dist/typescript/utils/generateNumbers.d.ts +0 -80
- package/dist/typescript/utils/getAdjustedLimit.d.ts +0 -30
- package/dist/typescript/utils/getDurationAndIndexFromScrollOffset.d.ts +0 -49
- package/dist/typescript/utils/getInitialScrollIndex.d.ts +0 -46
- package/dist/typescript/utils/getSafeInitialValue.d.ts +0 -38
- package/dist/typescript/utils/padNumber.d.ts +0 -28
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from \"./TimerPicker\";\n\nexport * from \"./types\";\n\nexport * from \"./styles\";\n\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,eAAe;AAEvC,cAAc,SAAS;AAEvB,cAAc,UAAU","ignoreList":[]}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from "react-native";
|
|
2
|
-
const DARK_MODE_BACKGROUND_COLOR = "#232323";
|
|
3
|
-
const DARK_MODE_TEXT_COLOR = "#E9E9E9";
|
|
4
|
-
const LIGHT_MODE_BACKGROUND_COLOR = "#F1F1F1";
|
|
5
|
-
const LIGHT_MODE_TEXT_COLOR = "#1B1B1B";
|
|
6
|
-
export const generateStyles = customStyles => {
|
|
7
|
-
var _customStyles$pickerL, _customStyles$text, _customStyles$pickerA, _customStyles$pickerL2, _customStyles$text2, _customStyles$pickerI, _customStyles$text3;
|
|
8
|
-
const backgroundColor = (customStyles === null || customStyles === void 0 ? void 0 : customStyles.backgroundColor) ?? ((customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? DARK_MODE_BACKGROUND_COLOR : LIGHT_MODE_BACKGROUND_COLOR);
|
|
9
|
-
const textColor = (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? DARK_MODE_TEXT_COLOR : LIGHT_MODE_TEXT_COLOR;
|
|
10
|
-
const pickerLabelFontSize = (customStyles === null || customStyles === void 0 || (_customStyles$pickerL = customStyles.pickerLabel) === null || _customStyles$pickerL === void 0 ? void 0 : _customStyles$pickerL.fontSize) ?? (customStyles === null || customStyles === void 0 || (_customStyles$text = customStyles.text) === null || _customStyles$text === void 0 ? void 0 : _customStyles$text.fontSize) ?? 18;
|
|
11
|
-
const pickerAmPmFontSize = (customStyles === null || customStyles === void 0 || (_customStyles$pickerA = customStyles.pickerAmPmLabel) === null || _customStyles$pickerA === void 0 ? void 0 : _customStyles$pickerA.fontSize) ?? (customStyles === null || customStyles === void 0 || (_customStyles$pickerL2 = customStyles.pickerLabel) === null || _customStyles$pickerL2 === void 0 ? void 0 : _customStyles$pickerL2.fontSize) ?? (customStyles === null || customStyles === void 0 || (_customStyles$text2 = customStyles.text) === null || _customStyles$text2 === void 0 ? void 0 : _customStyles$text2.fontSize) ?? 18;
|
|
12
|
-
const pickerItemFontSize = (customStyles === null || customStyles === void 0 || (_customStyles$pickerI = customStyles.pickerItem) === null || _customStyles$pickerI === void 0 ? void 0 : _customStyles$pickerI.fontSize) ?? (customStyles === null || customStyles === void 0 || (_customStyles$text3 = customStyles.text) === null || _customStyles$text3 === void 0 ? void 0 : _customStyles$text3.fontSize) ?? 25;
|
|
13
|
-
|
|
14
|
-
// This offset makes the picker label appear to be aligned with the picker item
|
|
15
|
-
// despite them having different font sizes
|
|
16
|
-
const pickerLabelVerticalOffset = pickerItemFontSize - pickerLabelFontSize - 1;
|
|
17
|
-
const pickerAmPmVerticalOffset = pickerItemFontSize - pickerAmPmFontSize - 1;
|
|
18
|
-
|
|
19
|
-
// The label is absolutely positioned, so we need to offset it for it to appear
|
|
20
|
-
// in the correct position. We offset it to the left of the container so that
|
|
21
|
-
// the width of the label doesn't impact its position.
|
|
22
|
-
const extraLabelOffsetPercentage = (customStyles === null || customStyles === void 0 ? void 0 : customStyles.labelOffsetPercentage) ?? 8;
|
|
23
|
-
const baseLeftOffsetPercentage = 70;
|
|
24
|
-
const labelOffsetPercentage = baseLeftOffsetPercentage + extraLabelOffsetPercentage;
|
|
25
|
-
return StyleSheet.create({
|
|
26
|
-
pickerContainer: {
|
|
27
|
-
flexDirection: "row",
|
|
28
|
-
backgroundColor,
|
|
29
|
-
width: "100%",
|
|
30
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerContainer)
|
|
31
|
-
},
|
|
32
|
-
pickerLabelContainer: {
|
|
33
|
-
position: "absolute",
|
|
34
|
-
top: 0,
|
|
35
|
-
bottom: 0,
|
|
36
|
-
left: `${labelOffsetPercentage}%`,
|
|
37
|
-
justifyContent: "center",
|
|
38
|
-
marginTop: pickerLabelVerticalOffset,
|
|
39
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerLabelContainer)
|
|
40
|
-
},
|
|
41
|
-
pickerLabel: {
|
|
42
|
-
fontSize: 18,
|
|
43
|
-
fontWeight: "bold",
|
|
44
|
-
color: textColor,
|
|
45
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.text),
|
|
46
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerLabel)
|
|
47
|
-
},
|
|
48
|
-
pickerItemContainer: {
|
|
49
|
-
flexDirection: "row",
|
|
50
|
-
height: 50,
|
|
51
|
-
justifyContent: "center",
|
|
52
|
-
alignItems: "center",
|
|
53
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItemContainer)
|
|
54
|
-
},
|
|
55
|
-
pickerItem: {
|
|
56
|
-
textAlignVertical: "center",
|
|
57
|
-
fontSize: 25,
|
|
58
|
-
overflow: "visible",
|
|
59
|
-
color: textColor,
|
|
60
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.text),
|
|
61
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerItem)
|
|
62
|
-
},
|
|
63
|
-
pickerAmPmContainer: {
|
|
64
|
-
position: "absolute",
|
|
65
|
-
top: 0,
|
|
66
|
-
bottom: 0,
|
|
67
|
-
left: `${labelOffsetPercentage}%`,
|
|
68
|
-
justifyContent: "center",
|
|
69
|
-
marginTop: pickerAmPmVerticalOffset,
|
|
70
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerLabelContainer),
|
|
71
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerAmPmContainer)
|
|
72
|
-
},
|
|
73
|
-
pickerAmPmLabel: {
|
|
74
|
-
fontSize: 18,
|
|
75
|
-
fontWeight: "bold",
|
|
76
|
-
color: textColor,
|
|
77
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.text),
|
|
78
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerLabel),
|
|
79
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerAmPmLabel)
|
|
80
|
-
},
|
|
81
|
-
disabledPickerContainer: {
|
|
82
|
-
opacity: 0.4,
|
|
83
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.disabledPickerContainer)
|
|
84
|
-
},
|
|
85
|
-
disabledPickerItem: {
|
|
86
|
-
opacity: 0.2,
|
|
87
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.disabledPickerItem)
|
|
88
|
-
},
|
|
89
|
-
maskedView: {
|
|
90
|
-
flex: 1
|
|
91
|
-
},
|
|
92
|
-
pickerGradientOverlay: {
|
|
93
|
-
position: "absolute",
|
|
94
|
-
width: "100%",
|
|
95
|
-
height: "100%",
|
|
96
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.pickerGradientOverlay)
|
|
97
|
-
},
|
|
98
|
-
durationScrollFlatListContainer: {
|
|
99
|
-
flex: 1,
|
|
100
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.durationScrollFlatListContainer)
|
|
101
|
-
},
|
|
102
|
-
durationScrollFlatList: {
|
|
103
|
-
// These paddings allow the inner am/pm label to
|
|
104
|
-
// spill out of the flatlist
|
|
105
|
-
paddingRight: "25%",
|
|
106
|
-
marginRight: "-25%",
|
|
107
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.durationScrollFlatList)
|
|
108
|
-
},
|
|
109
|
-
durationScrollFlatListContentContainer: {
|
|
110
|
-
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.durationScrollFlatListContentContainer)
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","DARK_MODE_BACKGROUND_COLOR","DARK_MODE_TEXT_COLOR","LIGHT_MODE_BACKGROUND_COLOR","LIGHT_MODE_TEXT_COLOR","generateStyles","customStyles","_customStyles$pickerL","_customStyles$text","_customStyles$pickerA","_customStyles$pickerL2","_customStyles$text2","_customStyles$pickerI","_customStyles$text3","backgroundColor","theme","textColor","pickerLabelFontSize","pickerLabel","fontSize","text","pickerAmPmFontSize","pickerAmPmLabel","pickerItemFontSize","pickerItem","pickerLabelVerticalOffset","pickerAmPmVerticalOffset","extraLabelOffsetPercentage","labelOffsetPercentage","baseLeftOffsetPercentage","create","pickerContainer","flexDirection","width","pickerLabelContainer","position","top","bottom","left","justifyContent","marginTop","fontWeight","color","pickerItemContainer","height","alignItems","textAlignVertical","overflow","pickerAmPmContainer","disabledPickerContainer","opacity","disabledPickerItem","maskedView","flex","pickerGradientOverlay","durationScrollFlatListContainer","durationScrollFlatList","paddingRight","marginRight","durationScrollFlatListContentContainer"],"sources":["styles.ts"],"sourcesContent":["import { StyleSheet } from \"react-native\";\nimport type { TextStyle, ViewStyle } from \"react-native\";\n\nexport interface CustomTimerPickerStyles {\n backgroundColor?: string;\n disabledPickerContainer?: ViewStyle;\n disabledPickerItem?: TextStyle;\n durationScrollFlatList?: ViewStyle;\n durationScrollFlatListContainer?: ViewStyle;\n durationScrollFlatListContentContainer?: ViewStyle;\n labelOffsetPercentage?: number;\n pickerAmPmContainer?: ViewStyle;\n pickerAmPmLabel?: TextStyle;\n pickerContainer?: ViewStyle & { backgroundColor?: string };\n pickerGradientOverlay?: ViewStyle;\n pickerItem?: TextStyle;\n pickerItemContainer?: ViewStyle & { height?: number };\n pickerLabel?: TextStyle;\n pickerLabelContainer?: ViewStyle;\n text?: TextStyle;\n theme?: \"light\" | \"dark\";\n}\n\nconst DARK_MODE_BACKGROUND_COLOR = \"#232323\";\nconst DARK_MODE_TEXT_COLOR = \"#E9E9E9\";\nconst LIGHT_MODE_BACKGROUND_COLOR = \"#F1F1F1\";\nconst LIGHT_MODE_TEXT_COLOR = \"#1B1B1B\";\n\nexport const generateStyles = (\n customStyles: CustomTimerPickerStyles | undefined\n) => {\n const backgroundColor =\n customStyles?.backgroundColor ??\n (customStyles?.theme === \"dark\"\n ? DARK_MODE_BACKGROUND_COLOR\n : LIGHT_MODE_BACKGROUND_COLOR);\n\n const textColor =\n customStyles?.theme === \"dark\"\n ? DARK_MODE_TEXT_COLOR\n : LIGHT_MODE_TEXT_COLOR;\n\n const pickerLabelFontSize =\n customStyles?.pickerLabel?.fontSize ??\n customStyles?.text?.fontSize ??\n 18;\n const pickerAmPmFontSize =\n customStyles?.pickerAmPmLabel?.fontSize ??\n customStyles?.pickerLabel?.fontSize ??\n customStyles?.text?.fontSize ??\n 18;\n const pickerItemFontSize =\n customStyles?.pickerItem?.fontSize ??\n customStyles?.text?.fontSize ??\n 25;\n\n // This offset makes the picker label appear to be aligned with the picker item\n // despite them having different font sizes\n const pickerLabelVerticalOffset =\n pickerItemFontSize - pickerLabelFontSize - 1;\n const pickerAmPmVerticalOffset =\n pickerItemFontSize - pickerAmPmFontSize - 1;\n\n // The label is absolutely positioned, so we need to offset it for it to appear\n // in the correct position. We offset it to the left of the container so that\n // the width of the label doesn't impact its position.\n const extraLabelOffsetPercentage = customStyles?.labelOffsetPercentage ?? 8;\n const baseLeftOffsetPercentage = 70;\n const labelOffsetPercentage =\n baseLeftOffsetPercentage + extraLabelOffsetPercentage;\n\n return StyleSheet.create({\n pickerContainer: {\n flexDirection: \"row\",\n backgroundColor,\n width: \"100%\",\n ...customStyles?.pickerContainer,\n },\n pickerLabelContainer: {\n position: \"absolute\",\n top: 0,\n bottom: 0,\n left: `${labelOffsetPercentage}%`,\n justifyContent: \"center\",\n marginTop: pickerLabelVerticalOffset,\n ...customStyles?.pickerLabelContainer,\n },\n pickerLabel: {\n fontSize: 18,\n fontWeight: \"bold\",\n color: textColor,\n ...customStyles?.text,\n ...customStyles?.pickerLabel,\n },\n pickerItemContainer: {\n flexDirection: \"row\",\n height: 50,\n justifyContent: \"center\",\n alignItems: \"center\",\n ...customStyles?.pickerItemContainer,\n },\n pickerItem: {\n textAlignVertical: \"center\",\n fontSize: 25,\n overflow: \"visible\",\n color: textColor,\n ...customStyles?.text,\n ...customStyles?.pickerItem,\n },\n pickerAmPmContainer: {\n position: \"absolute\",\n top: 0,\n bottom: 0,\n left: `${labelOffsetPercentage}%`,\n justifyContent: \"center\",\n marginTop: pickerAmPmVerticalOffset,\n ...customStyles?.pickerLabelContainer,\n ...customStyles?.pickerAmPmContainer,\n },\n pickerAmPmLabel: {\n fontSize: 18,\n fontWeight: \"bold\",\n color: textColor,\n ...customStyles?.text,\n ...customStyles?.pickerLabel,\n ...customStyles?.pickerAmPmLabel,\n },\n disabledPickerContainer: {\n opacity: 0.4,\n ...customStyles?.disabledPickerContainer,\n },\n disabledPickerItem: {\n opacity: 0.2,\n ...customStyles?.disabledPickerItem,\n },\n maskedView: {\n flex: 1,\n },\n pickerGradientOverlay: {\n position: \"absolute\",\n width: \"100%\",\n height: \"100%\",\n ...customStyles?.pickerGradientOverlay,\n },\n durationScrollFlatListContainer: {\n flex: 1,\n ...customStyles?.durationScrollFlatListContainer,\n },\n durationScrollFlatList: {\n // These paddings allow the inner am/pm label to\n // spill out of the flatlist\n paddingRight: \"25%\",\n marginRight: \"-25%\",\n ...customStyles?.durationScrollFlatList,\n },\n durationScrollFlatListContentContainer: {\n ...customStyles?.durationScrollFlatListContentContainer,\n },\n });\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAuBzC,MAAMC,0BAA0B,GAAG,SAAS;AAC5C,MAAMC,oBAAoB,GAAG,SAAS;AACtC,MAAMC,2BAA2B,GAAG,SAAS;AAC7C,MAAMC,qBAAqB,GAAG,SAAS;AAEvC,OAAO,M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;MACZ,IAAG5C,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAE6C,kBAAkB;IACvC,CAAC;IACDC,UAAU,EAAE;MACRC,IAAI,EAAE;IACV,CAAC;IACDC,qBAAqB,EAAE;MACnBnB,QAAQ,EAAE,UAAU;MACpBF,KAAK,EAAE,MAAM;MACbW,MAAM,EAAE,MAAM;MACd,IAAGtC,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEgD,qBAAqB;IAC1C,CAAC;IACDC,+BAA+B,EAAE;MAC7BF,IAAI,EAAE,CAAC;MACP,IAAG/C,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEiD,+BAA+B;IACpD,CAAC;IACDC,sBAAsB,EAAE;MACpB;MACA;MACAC,YAAY,EAAE,KAAK;MACnBC,WAAW,EAAE,MAAM;MACnB,IAAGpD,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEkD,sBAAsB;IAC3C,CAAC;IACDG,sCAAsC,EAAE;MACpC,IAAGrD,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEqD,sCAAsC;IAC3D;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { RefObject } from \"react\";\n\nimport type { View } from \"react-native\";\n\nimport type {\n LinearGradientProps,\n SoundAsset,\n Limit,\n} from \"../DurationScroll/types\";\n\nimport type { CustomTimerPickerStyles } from \"./styles\";\n\nexport interface TimerPickerRef {\n latestDuration: {\n days: RefObject<number> | undefined;\n hours: RefObject<number> | undefined;\n minutes: RefObject<number> | undefined;\n seconds: RefObject<number> | undefined;\n };\n reset: (options?: { animated?: boolean }) => void;\n setValue: (\n value: {\n days?: number;\n hours?: number;\n minutes?: number;\n seconds?: number;\n },\n options?: { animated?: boolean }\n ) => void;\n}\n\nexport interface TimerPickerProps {\n /** @deprecated Use pickerFeedback prop instead. Will be removed in a future version. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Audio?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n FlatList?: any;\n /** @deprecated Use pickerFeedback prop instead. Will be removed in a future version. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Haptics?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n LinearGradient?: any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n MaskedView?: any;\n aggressivelyGetLatestDuration?: boolean;\n allowFontScaling?: boolean;\n amLabel?: string;\n /** @deprecated Use pickerFeedback prop instead. Will be removed in a future version. */\n clickSoundAsset?: SoundAsset;\n dayInterval?: number;\n dayLabel?: string | React.ReactElement;\n dayLimit?: Limit;\n daysPickerIsDisabled?: boolean;\n decelerationRate?: number | \"normal\" | \"fast\";\n disableInfiniteScroll?: boolean;\n hideDays?: boolean;\n hideHours?: boolean;\n hideMinutes?: boolean;\n hideSeconds?: boolean;\n hourInterval?: number;\n hourLabel?: string | React.ReactElement;\n hourLimit?: Limit;\n hoursPickerIsDisabled?: boolean;\n initialValue?: {\n days?: number;\n hours?: number;\n minutes?: number;\n seconds?: number;\n };\n maximumDays?: number;\n maximumHours?: number;\n maximumMinutes?: number;\n maximumSeconds?: number;\n minuteInterval?: number;\n minuteLabel?: string | React.ReactElement;\n minuteLimit?: Limit;\n minutesPickerIsDisabled?: boolean;\n onDurationChange?: (duration: {\n days: number;\n hours: number;\n minutes: number;\n seconds: number;\n }) => void;\n padDaysWithZero?: boolean;\n padHoursWithZero?: boolean;\n padMinutesWithZero?: boolean;\n padSecondsWithZero?: boolean;\n padWithNItems?: number;\n pickerContainerProps?: React.ComponentProps<typeof View>;\n pickerFeedback?: () => void | Promise<void>;\n pickerGradientOverlayProps?: Partial<LinearGradientProps>;\n pmLabel?: string;\n repeatDayNumbersNTimes?: number;\n repeatHourNumbersNTimes?: number;\n repeatMinuteNumbersNTimes?: number;\n repeatSecondNumbersNTimes?: number;\n secondInterval?: number;\n secondLabel?: string | React.ReactElement;\n secondLimit?: Limit;\n secondsPickerIsDisabled?: boolean;\n styles?: CustomTimerPickerStyles;\n use12HourPicker?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
3
|
-
import { View, Text, TouchableOpacity } from "react-native";
|
|
4
|
-
import { getSafeInitialValue } from "../../utils/getSafeInitialValue";
|
|
5
|
-
import Modal from "../Modal";
|
|
6
|
-
import TimerPicker from "../TimerPicker";
|
|
7
|
-
import { generateStyles } from "./styles";
|
|
8
|
-
const TimerPickerModal = /*#__PURE__*/forwardRef((props, ref) => {
|
|
9
|
-
const {
|
|
10
|
-
buttonContainerProps,
|
|
11
|
-
buttonTouchableOpacityProps,
|
|
12
|
-
cancelButtonText = "Cancel",
|
|
13
|
-
closeOnOverlayPress,
|
|
14
|
-
confirmButtonText = "Confirm",
|
|
15
|
-
containerProps,
|
|
16
|
-
contentContainerProps,
|
|
17
|
-
hideCancelButton = false,
|
|
18
|
-
initialValue,
|
|
19
|
-
modalProps,
|
|
20
|
-
modalTitle,
|
|
21
|
-
modalTitleProps,
|
|
22
|
-
onCancel,
|
|
23
|
-
onConfirm,
|
|
24
|
-
onDurationChange,
|
|
25
|
-
setIsVisible,
|
|
26
|
-
styles: customStyles,
|
|
27
|
-
visible,
|
|
28
|
-
...otherProps
|
|
29
|
-
} = props;
|
|
30
|
-
const styles = generateStyles(customStyles, {
|
|
31
|
-
hasModalTitle: Boolean(modalTitle)
|
|
32
|
-
});
|
|
33
|
-
const timerPickerRef = useRef(null);
|
|
34
|
-
const safeInitialValue = getSafeInitialValue({
|
|
35
|
-
days: initialValue === null || initialValue === void 0 ? void 0 : initialValue.days,
|
|
36
|
-
hours: initialValue === null || initialValue === void 0 ? void 0 : initialValue.hours,
|
|
37
|
-
minutes: initialValue === null || initialValue === void 0 ? void 0 : initialValue.minutes,
|
|
38
|
-
seconds: initialValue === null || initialValue === void 0 ? void 0 : initialValue.seconds
|
|
39
|
-
});
|
|
40
|
-
const [selectedDuration, setSelectedDuration] = useState(safeInitialValue);
|
|
41
|
-
const [confirmedDuration, setConfirmedDuration] = useState(safeInitialValue);
|
|
42
|
-
const reset = options => {
|
|
43
|
-
var _timerPickerRef$curre;
|
|
44
|
-
setSelectedDuration(safeInitialValue);
|
|
45
|
-
setConfirmedDuration(safeInitialValue);
|
|
46
|
-
(_timerPickerRef$curre = timerPickerRef.current) === null || _timerPickerRef$curre === void 0 || _timerPickerRef$curre.reset(options);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// reset state if the initial value changes
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
reset();
|
|
52
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
-
}, [safeInitialValue.days, safeInitialValue.hours, safeInitialValue.minutes, safeInitialValue.seconds]);
|
|
54
|
-
const hideModalHandler = () => {
|
|
55
|
-
setSelectedDuration({
|
|
56
|
-
days: confirmedDuration.days,
|
|
57
|
-
hours: confirmedDuration.hours,
|
|
58
|
-
minutes: confirmedDuration.minutes,
|
|
59
|
-
seconds: confirmedDuration.seconds
|
|
60
|
-
});
|
|
61
|
-
setIsVisible(false);
|
|
62
|
-
};
|
|
63
|
-
const confirmHandler = () => {
|
|
64
|
-
var _timerPickerRef$curre2, _latestDuration$days, _latestDuration$hours, _latestDuration$minut, _latestDuration$secon;
|
|
65
|
-
const latestDuration = (_timerPickerRef$curre2 = timerPickerRef.current) === null || _timerPickerRef$curre2 === void 0 ? void 0 : _timerPickerRef$curre2.latestDuration;
|
|
66
|
-
const newDuration = {
|
|
67
|
-
days: (latestDuration === null || latestDuration === void 0 || (_latestDuration$days = latestDuration.days) === null || _latestDuration$days === void 0 ? void 0 : _latestDuration$days.current) ?? selectedDuration.days,
|
|
68
|
-
hours: (latestDuration === null || latestDuration === void 0 || (_latestDuration$hours = latestDuration.hours) === null || _latestDuration$hours === void 0 ? void 0 : _latestDuration$hours.current) ?? selectedDuration.hours,
|
|
69
|
-
minutes: (latestDuration === null || latestDuration === void 0 || (_latestDuration$minut = latestDuration.minutes) === null || _latestDuration$minut === void 0 ? void 0 : _latestDuration$minut.current) ?? selectedDuration.minutes,
|
|
70
|
-
seconds: (latestDuration === null || latestDuration === void 0 || (_latestDuration$secon = latestDuration.seconds) === null || _latestDuration$secon === void 0 ? void 0 : _latestDuration$secon.current) ?? selectedDuration.seconds
|
|
71
|
-
};
|
|
72
|
-
setConfirmedDuration(newDuration);
|
|
73
|
-
onConfirm(newDuration);
|
|
74
|
-
};
|
|
75
|
-
const cancelHandler = () => {
|
|
76
|
-
setIsVisible(false);
|
|
77
|
-
setSelectedDuration(confirmedDuration);
|
|
78
|
-
onCancel === null || onCancel === void 0 || onCancel();
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// wrapped in useCallback to avoid unnecessary re-renders of TimerPicker
|
|
82
|
-
const durationChangeHandler = useCallback(duration => {
|
|
83
|
-
setSelectedDuration(duration);
|
|
84
|
-
onDurationChange === null || onDurationChange === void 0 || onDurationChange(duration);
|
|
85
|
-
}, [onDurationChange]);
|
|
86
|
-
useImperativeHandle(ref, () => {
|
|
87
|
-
var _timerPickerRef$curre4, _timerPickerRef$curre5, _timerPickerRef$curre6, _timerPickerRef$curre7;
|
|
88
|
-
return {
|
|
89
|
-
reset,
|
|
90
|
-
setValue: (value, options) => {
|
|
91
|
-
var _timerPickerRef$curre3;
|
|
92
|
-
setSelectedDuration(prev => ({
|
|
93
|
-
...prev,
|
|
94
|
-
...value
|
|
95
|
-
}));
|
|
96
|
-
setConfirmedDuration(prev => ({
|
|
97
|
-
...prev,
|
|
98
|
-
...value
|
|
99
|
-
}));
|
|
100
|
-
(_timerPickerRef$curre3 = timerPickerRef.current) === null || _timerPickerRef$curre3 === void 0 || _timerPickerRef$curre3.setValue(value, options);
|
|
101
|
-
},
|
|
102
|
-
latestDuration: {
|
|
103
|
-
days: (_timerPickerRef$curre4 = timerPickerRef.current) === null || _timerPickerRef$curre4 === void 0 || (_timerPickerRef$curre4 = _timerPickerRef$curre4.latestDuration) === null || _timerPickerRef$curre4 === void 0 ? void 0 : _timerPickerRef$curre4.days,
|
|
104
|
-
hours: (_timerPickerRef$curre5 = timerPickerRef.current) === null || _timerPickerRef$curre5 === void 0 || (_timerPickerRef$curre5 = _timerPickerRef$curre5.latestDuration) === null || _timerPickerRef$curre5 === void 0 ? void 0 : _timerPickerRef$curre5.hours,
|
|
105
|
-
minutes: (_timerPickerRef$curre6 = timerPickerRef.current) === null || _timerPickerRef$curre6 === void 0 || (_timerPickerRef$curre6 = _timerPickerRef$curre6.latestDuration) === null || _timerPickerRef$curre6 === void 0 ? void 0 : _timerPickerRef$curre6.minutes,
|
|
106
|
-
seconds: (_timerPickerRef$curre7 = timerPickerRef.current) === null || _timerPickerRef$curre7 === void 0 || (_timerPickerRef$curre7 = _timerPickerRef$curre7.latestDuration) === null || _timerPickerRef$curre7 === void 0 ? void 0 : _timerPickerRef$curre7.seconds
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
return /*#__PURE__*/React.createElement(Modal, _extends({
|
|
111
|
-
isVisible: visible,
|
|
112
|
-
onOverlayPress: closeOnOverlayPress ? hideModalHandler : undefined
|
|
113
|
-
}, modalProps, {
|
|
114
|
-
testID: "timer-picker-modal"
|
|
115
|
-
}), /*#__PURE__*/React.createElement(View, _extends({}, containerProps, {
|
|
116
|
-
style: styles.container
|
|
117
|
-
}), /*#__PURE__*/React.createElement(View, _extends({}, contentContainerProps, {
|
|
118
|
-
style: styles.contentContainer
|
|
119
|
-
}), modalTitle ? /*#__PURE__*/React.createElement(Text, _extends({}, modalTitleProps, {
|
|
120
|
-
style: styles.modalTitle
|
|
121
|
-
}), modalTitle) : null, /*#__PURE__*/React.createElement(TimerPicker, _extends({
|
|
122
|
-
ref: timerPickerRef,
|
|
123
|
-
initialValue: confirmedDuration
|
|
124
|
-
}, otherProps, {
|
|
125
|
-
aggressivelyGetLatestDuration: true,
|
|
126
|
-
onDurationChange: durationChangeHandler,
|
|
127
|
-
styles: styles.timerPickerStyles
|
|
128
|
-
})), /*#__PURE__*/React.createElement(View, _extends({}, buttonContainerProps, {
|
|
129
|
-
style: styles.buttonContainer
|
|
130
|
-
}), !hideCancelButton ? /*#__PURE__*/React.isValidElement(props.cancelButton) ? /*#__PURE__*/React.cloneElement(props.cancelButton, {
|
|
131
|
-
onPress: cancelHandler
|
|
132
|
-
}) : /*#__PURE__*/React.createElement(TouchableOpacity, _extends({}, buttonTouchableOpacityProps, {
|
|
133
|
-
onPress: cancelHandler
|
|
134
|
-
}), /*#__PURE__*/React.createElement(Text, {
|
|
135
|
-
style: [styles.button, styles.cancelButton]
|
|
136
|
-
}, cancelButtonText)) : null, /*#__PURE__*/React.isValidElement(props.confirmButton) ? /*#__PURE__*/React.cloneElement(props.confirmButton, {
|
|
137
|
-
onPress: confirmHandler
|
|
138
|
-
}) : /*#__PURE__*/React.createElement(TouchableOpacity, _extends({}, buttonTouchableOpacityProps, {
|
|
139
|
-
onPress: confirmHandler
|
|
140
|
-
}), /*#__PURE__*/React.createElement(Text, {
|
|
141
|
-
style: [styles.button, styles.confirmButton]
|
|
142
|
-
}, confirmButtonText))))));
|
|
143
|
-
});
|
|
144
|
-
export default /*#__PURE__*/React.memo(TimerPickerModal);
|
|
145
|
-
//# sourceMappingURL=TimerPickerModal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","View","Text","TouchableOpacity","getSafeInitialValue","Modal","TimerPicker","generateStyles","TimerPickerModal","props","ref","buttonContainerProps","buttonTouchableOpacityProps","cancelButtonText","closeOnOverlayPress","confirmButtonText","containerProps","contentContainerProps","hideCancelButton","initialValue","modalProps","modalTitle","modalTitleProps","onCancel","onConfirm","onDurationChange","setIsVisible","styles","customStyles","visible","otherProps","hasModalTitle","Boolean","timerPickerRef","safeInitialValue","days","hours","minutes","seconds","selectedDuration","setSelectedDuration","confirmedDuration","setConfirmedDuration","reset","options","_timerPickerRef$curre","current","hideModalHandler","confirmHandler","_timerPickerRef$curre2","_latestDuration$days","_latestDuration$hours","_latestDuration$minut","_latestDuration$secon","latestDuration","newDuration","cancelHandler","durationChangeHandler","duration","_timerPickerRef$curre4","_timerPickerRef$curre5","_timerPickerRef$curre6","_timerPickerRef$curre7","setValue","value","_timerPickerRef$curre3","prev","createElement","_extends","isVisible","onOverlayPress","undefined","testID","style","container","contentContainer","aggressivelyGetLatestDuration","timerPickerStyles","buttonContainer","isValidElement","cancelButton","cloneElement","onPress","button","confirmButton","memo"],"sources":["TimerPickerModal.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from \"react\";\n\nimport { View, Text, TouchableOpacity } from \"react-native\";\n\nimport { getSafeInitialValue } from \"../../utils/getSafeInitialValue\";\nimport Modal from \"../Modal\";\nimport TimerPicker from \"../TimerPicker\";\nimport type { TimerPickerRef } from \"../TimerPicker\";\n\nimport { generateStyles } from \"./styles\";\nimport type { TimerPickerModalRef, TimerPickerModalProps } from \"./types\";\n\nconst TimerPickerModal = forwardRef<TimerPickerModalRef, TimerPickerModalProps>(\n (props, ref) => {\n const {\n buttonContainerProps,\n buttonTouchableOpacityProps,\n cancelButtonText = \"Cancel\",\n closeOnOverlayPress,\n confirmButtonText = \"Confirm\",\n containerProps,\n contentContainerProps,\n hideCancelButton = false,\n initialValue,\n modalProps,\n modalTitle,\n modalTitleProps,\n onCancel,\n onConfirm,\n onDurationChange,\n setIsVisible,\n styles: customStyles,\n visible,\n ...otherProps\n } = props;\n\n const styles = generateStyles(customStyles, {\n hasModalTitle: Boolean(modalTitle),\n });\n\n const timerPickerRef = useRef<TimerPickerRef>(null);\n\n const safeInitialValue = getSafeInitialValue({\n days: initialValue?.days,\n hours: initialValue?.hours,\n minutes: initialValue?.minutes,\n seconds: initialValue?.seconds,\n });\n\n const [selectedDuration, setSelectedDuration] =\n useState(safeInitialValue);\n const [confirmedDuration, setConfirmedDuration] =\n useState(safeInitialValue);\n\n const reset = (options?: { animated?: boolean }) => {\n setSelectedDuration(safeInitialValue);\n setConfirmedDuration(safeInitialValue);\n timerPickerRef.current?.reset(options);\n };\n\n // reset state if the initial value changes\n useEffect(() => {\n reset();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n safeInitialValue.days,\n safeInitialValue.hours,\n safeInitialValue.minutes,\n safeInitialValue.seconds,\n ]);\n\n const hideModalHandler = () => {\n setSelectedDuration({\n days: confirmedDuration.days,\n hours: confirmedDuration.hours,\n minutes: confirmedDuration.minutes,\n seconds: confirmedDuration.seconds,\n });\n setIsVisible(false);\n };\n\n const confirmHandler = () => {\n const latestDuration = timerPickerRef.current?.latestDuration;\n\n const newDuration = {\n days: latestDuration?.days?.current ?? selectedDuration.days,\n hours: latestDuration?.hours?.current ?? selectedDuration.hours,\n minutes:\n latestDuration?.minutes?.current ??\n selectedDuration.minutes,\n seconds:\n latestDuration?.seconds?.current ??\n selectedDuration.seconds,\n };\n setConfirmedDuration(newDuration);\n onConfirm(newDuration);\n };\n\n const cancelHandler = () => {\n setIsVisible(false);\n setSelectedDuration(confirmedDuration);\n onCancel?.();\n };\n\n // wrapped in useCallback to avoid unnecessary re-renders of TimerPicker\n const durationChangeHandler = useCallback(\n (duration: {\n days: number;\n hours: number;\n minutes: number;\n seconds: number;\n }) => {\n setSelectedDuration(duration);\n onDurationChange?.(duration);\n },\n [onDurationChange]\n );\n\n useImperativeHandle(ref, () => ({\n reset,\n setValue: (value, options) => {\n setSelectedDuration((prev) => ({\n ...prev,\n ...value,\n }));\n setConfirmedDuration((prev) => ({\n ...prev,\n ...value,\n }));\n timerPickerRef.current?.setValue(value, options);\n },\n latestDuration: {\n days: timerPickerRef.current?.latestDuration?.days,\n hours: timerPickerRef.current?.latestDuration?.hours,\n minutes: timerPickerRef.current?.latestDuration?.minutes,\n seconds: timerPickerRef.current?.latestDuration?.seconds,\n },\n }));\n\n return (\n <Modal\n isVisible={visible}\n onOverlayPress={\n closeOnOverlayPress ? hideModalHandler : undefined\n }\n {...modalProps}\n testID=\"timer-picker-modal\">\n <View {...containerProps} style={styles.container}>\n <View\n {...contentContainerProps}\n style={styles.contentContainer}>\n {modalTitle ? (\n <Text\n {...modalTitleProps}\n style={styles.modalTitle}>\n {modalTitle}\n </Text>\n ) : null}\n <TimerPicker\n ref={timerPickerRef}\n initialValue={confirmedDuration}\n {...otherProps}\n aggressivelyGetLatestDuration\n onDurationChange={durationChangeHandler}\n styles={styles.timerPickerStyles}\n />\n <View\n {...buttonContainerProps}\n style={styles.buttonContainer}>\n {!hideCancelButton\n ? (\n React.isValidElement(props.cancelButton)\n ? React.cloneElement(\n props.cancelButton,\n {\n onPress: cancelHandler,\n }\n )\n : (\n <TouchableOpacity\n {...buttonTouchableOpacityProps}\n onPress={cancelHandler}>\n <Text\n style={[\n styles.button,\n styles.cancelButton,\n ]}>\n {cancelButtonText}\n </Text>\n </TouchableOpacity>\n )\n )\n : null}\n {React.isValidElement(props.confirmButton)\n ? React.cloneElement(props.confirmButton, {\n onPress: confirmHandler,\n })\n : (\n <TouchableOpacity\n {...buttonTouchableOpacityProps}\n onPress={confirmHandler}>\n <Text\n style={[\n styles.button,\n styles.confirmButton,\n ]}>\n {confirmButtonText}\n </Text>\n </TouchableOpacity>\n )}\n </View>\n </View>\n </View>\n </Modal>\n );\n }\n);\n\nexport default React.memo(TimerPickerModal);\n"],"mappings":";AAAA,OAAOA,KAAK,IACRC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACL,OAAO;AAEd,SAASC,I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AAO,EAAElC;EACb,CAAC,CAAC,gBAEEtD,KAAA,CAAAyE,aAAA,CAAChE,gBAAgB,EAAAiE,QAAA,KACTxD,2BAA2B;IAC/BsE,OAAO,EAAElC;EAAe,iBACxBtD,KAAA,CAAAyE,aAAA,CAACjE,IAAI;IACDuE,KAAK,EAAE,CACH9C,MAAM,CAACwD,MAAM,EACbxD,MAAM,CAACyD,aAAa;EACtB,GACDrE,iBACC,CACQ,CAExB,CACJ,CACJ,CACH,CAAC;AAEhB,CACJ,CAAC;AAED,4BAAerB,KAAK,CAAC2F,IAAI,CAAC7E,gBAAgB,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from \"./TimerPickerModal\";\n\nexport * from \"./types\";\n\nexport * from \"./styles\";\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,oBAAoB;AAE5C,cAAc,SAAS;AAEvB,cAAc,UAAU","ignoreList":[]}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from "react-native";
|
|
2
|
-
const DARK_MODE_BACKGROUND_COLOR = "#232323";
|
|
3
|
-
const DARK_MODE_TEXT_COLOR = "#E9E9E9";
|
|
4
|
-
const LIGHT_MODE_BACKGROUND_COLOR = "#F1F1F1";
|
|
5
|
-
const LIGHT_MODE_TEXT_COLOR = "#1B1B1B";
|
|
6
|
-
export const generateStyles = (customStyles, variables) => {
|
|
7
|
-
const {
|
|
8
|
-
button: customButtonStyle,
|
|
9
|
-
buttonContainer: customButtonContainerStyle,
|
|
10
|
-
cancelButton: customCancelButtonStyle,
|
|
11
|
-
confirmButton: customConfirmButtonStyle,
|
|
12
|
-
container: customContainerStyle,
|
|
13
|
-
contentContainer: customContentContainerStyle,
|
|
14
|
-
modalTitle: customModalTitleStyle,
|
|
15
|
-
...customTimerPickerStyles
|
|
16
|
-
} = customStyles ?? {};
|
|
17
|
-
return StyleSheet.create({
|
|
18
|
-
container: {
|
|
19
|
-
justifyContent: "center",
|
|
20
|
-
overflow: "hidden",
|
|
21
|
-
...customContainerStyle
|
|
22
|
-
},
|
|
23
|
-
contentContainer: {
|
|
24
|
-
backgroundColor: (customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.backgroundColor) ?? ((customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.theme) === "dark" ? DARK_MODE_BACKGROUND_COLOR : LIGHT_MODE_BACKGROUND_COLOR),
|
|
25
|
-
justifyContent: "center",
|
|
26
|
-
alignItems: "center",
|
|
27
|
-
borderRadius: 20,
|
|
28
|
-
overflow: "hidden",
|
|
29
|
-
paddingHorizontal: 20,
|
|
30
|
-
...customContentContainerStyle
|
|
31
|
-
},
|
|
32
|
-
buttonContainer: {
|
|
33
|
-
flexDirection: "row",
|
|
34
|
-
marginTop: 25,
|
|
35
|
-
marginBottom: 20,
|
|
36
|
-
...customButtonContainerStyle
|
|
37
|
-
},
|
|
38
|
-
button: {
|
|
39
|
-
marginHorizontal: 12,
|
|
40
|
-
paddingVertical: 10,
|
|
41
|
-
paddingHorizontal: 20,
|
|
42
|
-
borderWidth: 1,
|
|
43
|
-
borderRadius: 10,
|
|
44
|
-
fontSize: 16,
|
|
45
|
-
overflow: "hidden",
|
|
46
|
-
...(customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.text),
|
|
47
|
-
...customButtonStyle
|
|
48
|
-
},
|
|
49
|
-
cancelButton: {
|
|
50
|
-
borderColor: "gray",
|
|
51
|
-
color: (customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.theme) === "dark" ? DARK_MODE_TEXT_COLOR : "gray",
|
|
52
|
-
backgroundColor: (customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.theme) === "dark" ? "gray" : undefined,
|
|
53
|
-
...(customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.text),
|
|
54
|
-
...customCancelButtonStyle
|
|
55
|
-
},
|
|
56
|
-
confirmButton: {
|
|
57
|
-
borderColor: "green",
|
|
58
|
-
color: (customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.theme) === "dark" ? DARK_MODE_TEXT_COLOR : "green",
|
|
59
|
-
backgroundColor: (customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.theme) === "dark" ? "green" : undefined,
|
|
60
|
-
...(customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.text),
|
|
61
|
-
...customConfirmButtonStyle
|
|
62
|
-
},
|
|
63
|
-
modalTitle: {
|
|
64
|
-
fontSize: 24,
|
|
65
|
-
fontWeight: "600",
|
|
66
|
-
marginTop: 20,
|
|
67
|
-
marginBottom: 15,
|
|
68
|
-
color: (customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.theme) === "dark" ? DARK_MODE_TEXT_COLOR : LIGHT_MODE_TEXT_COLOR,
|
|
69
|
-
...(customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.text),
|
|
70
|
-
...customModalTitleStyle
|
|
71
|
-
},
|
|
72
|
-
timerPickerStyles: {
|
|
73
|
-
...customTimerPickerStyles,
|
|
74
|
-
pickerContainer: {
|
|
75
|
-
marginRight: "8%",
|
|
76
|
-
paddingTop: !(variables !== null && variables !== void 0 && variables.hasModalTitle) ? 20 : 0,
|
|
77
|
-
...((customTimerPickerStyles === null || customTimerPickerStyles === void 0 ? void 0 : customTimerPickerStyles.pickerContainer) ?? {})
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","DARK_MODE_BACKGROUND_COLOR","DARK_MODE_TEXT_COLOR","LIGHT_MODE_BACKGROUND_COLOR","LIGHT_MODE_TEXT_COLOR","generateStyles","customStyles","variables","button","customButtonStyle","buttonContainer","customButtonContainerStyle","cancelButton","customCancelButtonStyle","confirmButton","customConfirmButtonStyle","container","customContainerStyle","contentContainer","customContentContainerStyle","modalTitle","customModalTitleStyle","customTimerPickerStyles","create","justifyContent","overflow","backgroundColor","theme","alignItems","borderRadius","paddingHorizontal","flexDirection","marginTop","marginBottom","marginHorizontal","paddingVertical","borderWidth","fontSize","text","borderColor","color","undefined","fontWeight","timerPickerStyles","pickerContainer","marginRight","paddingTop","hasModalTitle"],"sources":["styles.ts"],"sourcesContent":["import { StyleSheet } from \"react-native\";\nimport type { DimensionValue, TextStyle, ViewStyle } from \"react-native\";\n\nimport type { CustomTimerPickerStyles } from \"../TimerPicker/styles\";\n\nexport interface CustomTimerPickerModalStyles extends CustomTimerPickerStyles {\n button?: TextStyle;\n buttonContainer?: ViewStyle;\n cancelButton?: TextStyle;\n confirmButton?: TextStyle;\n container?: ViewStyle;\n contentContainer?: ViewStyle;\n modalTitle?: TextStyle;\n}\n\nconst DARK_MODE_BACKGROUND_COLOR = \"#232323\";\nconst DARK_MODE_TEXT_COLOR = \"#E9E9E9\";\nconst LIGHT_MODE_BACKGROUND_COLOR = \"#F1F1F1\";\nconst LIGHT_MODE_TEXT_COLOR = \"#1B1B1B\";\n\nexport const generateStyles = (\n customStyles: CustomTimerPickerModalStyles | undefined,\n variables?: {\n hasModalTitle: boolean;\n }\n) => {\n const {\n button: customButtonStyle,\n buttonContainer: customButtonContainerStyle,\n cancelButton: customCancelButtonStyle,\n confirmButton: customConfirmButtonStyle,\n container: customContainerStyle,\n contentContainer: customContentContainerStyle,\n modalTitle: customModalTitleStyle,\n ...customTimerPickerStyles\n } = customStyles ?? {};\n\n return StyleSheet.create({\n container: {\n justifyContent: \"center\",\n overflow: \"hidden\",\n ...customContainerStyle,\n },\n contentContainer: {\n backgroundColor:\n customTimerPickerStyles?.backgroundColor ??\n (customTimerPickerStyles?.theme === \"dark\"\n ? DARK_MODE_BACKGROUND_COLOR\n : LIGHT_MODE_BACKGROUND_COLOR),\n justifyContent: \"center\",\n alignItems: \"center\",\n borderRadius: 20,\n overflow: \"hidden\",\n paddingHorizontal: 20,\n ...customContentContainerStyle,\n },\n buttonContainer: {\n flexDirection: \"row\",\n marginTop: 25,\n marginBottom: 20,\n ...customButtonContainerStyle,\n },\n button: {\n marginHorizontal: 12,\n paddingVertical: 10,\n paddingHorizontal: 20,\n borderWidth: 1,\n borderRadius: 10,\n fontSize: 16,\n overflow: \"hidden\",\n ...customTimerPickerStyles?.text,\n ...customButtonStyle,\n },\n cancelButton: {\n borderColor: \"gray\",\n color:\n customTimerPickerStyles?.theme === \"dark\"\n ? DARK_MODE_TEXT_COLOR\n : \"gray\",\n backgroundColor:\n customTimerPickerStyles?.theme === \"dark\" ? \"gray\" : undefined,\n ...customTimerPickerStyles?.text,\n ...customCancelButtonStyle,\n },\n confirmButton: {\n borderColor: \"green\",\n color:\n customTimerPickerStyles?.theme === \"dark\"\n ? DARK_MODE_TEXT_COLOR\n : \"green\",\n backgroundColor:\n customTimerPickerStyles?.theme === \"dark\" ? \"green\" : undefined,\n ...customTimerPickerStyles?.text,\n ...customConfirmButtonStyle,\n },\n modalTitle: {\n fontSize: 24,\n fontWeight: \"600\",\n marginTop: 20,\n marginBottom: 15,\n color:\n customTimerPickerStyles?.theme === \"dark\"\n ? DARK_MODE_TEXT_COLOR\n : LIGHT_MODE_TEXT_COLOR,\n ...customTimerPickerStyles?.text,\n ...customModalTitleStyle,\n },\n timerPickerStyles: {\n ...customTimerPickerStyles,\n pickerContainer: {\n marginRight: \"8%\" as DimensionValue,\n paddingTop: !variables?.hasModalTitle ? 20 : 0,\n ...(customTimerPickerStyles?.pickerContainer ?? {}),\n },\n },\n });\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAezC,MAAMC,0BAA0B,GAAG,SAAS;AAC5C,MAAMC,oBA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,GAAGjB;IACP,CAAC;IACDsB,iBAAiB,EAAE;MACf,GAAGrB,uBAAuB;MAC1BsB,eAAe,EAAE;QACbC,WAAW,EAAE,IAAsB;QACnCC,UAAU,EAAE,EAACvC,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEwC,aAAa,IAAG,EAAE,GAAG,CAAC;QAC9C,IAAI,CAAAzB,uBAAuB,aAAvBA,uBAAuB,uBAAvBA,uBAAuB,CAAEsB,eAAe,KAAI,CAAC,CAAC;MACtD;IACJ;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { RefObject, ReactElement } from \"react\";\n\nimport type { View, TouchableOpacity, Text } from \"react-native\";\n\nimport type Modal from \"../Modal\";\nimport type { TimerPickerProps } from \"../TimerPicker/types\";\n\nimport type { CustomTimerPickerModalStyles } from \"./styles\";\n\nexport interface TimerPickerModalRef {\n latestDuration: {\n days: RefObject<number> | undefined;\n hours: RefObject<number> | undefined;\n minutes: RefObject<number> | undefined;\n seconds: RefObject<number> | undefined;\n };\n reset: (options?: { animated?: boolean }) => void;\n setValue: (\n value: {\n days?: number;\n hours?: number;\n minutes?: number;\n seconds?: number;\n },\n options?: { animated?: boolean }\n ) => void;\n}\n\nexport interface TimerPickerModalProps extends TimerPickerProps {\n buttonContainerProps?: React.ComponentProps<typeof View>;\n buttonTouchableOpacityProps?: React.ComponentProps<typeof TouchableOpacity>;\n /** Custom cancel button component. If provided, replaces the default cancel button. */\n cancelButton?: ReactElement<{ onPress?: () => void }>;\n cancelButtonText?: string;\n closeOnOverlayPress?: boolean;\n /** Custom confirm button component. If provided, replaces the default confirm button. */\n confirmButton?: ReactElement<{ onPress?: () => void }>;\n confirmButtonText?: string;\n containerProps?: React.ComponentProps<typeof View>;\n contentContainerProps?: React.ComponentProps<typeof View>;\n hideCancelButton?: boolean;\n modalProps?: React.ComponentProps<typeof Modal>;\n modalTitle?: string;\n modalTitleProps?: React.ComponentProps<typeof Text>;\n onCancel?: () => void;\n onConfirm: ({\n days,\n hours,\n minutes,\n seconds,\n }: {\n days: number;\n hours: number;\n minutes: number;\n seconds: number;\n }) => void;\n setIsVisible: (isVisible: boolean) => void;\n styles?: CustomTimerPickerModalStyles;\n visible: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
package/dist/module/index.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { default as TimerPickerModal, TimerPickerModalProps, TimerPickerModalRef, CustomTimerPickerModalStyles } from "./components/TimerPickerModal";
|
|
2
|
-
export { default as TimerPicker, TimerPickerProps, TimerPickerRef, CustomTimerPickerStyles } from "./components/TimerPicker";
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
package/dist/module/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["default","TimerPickerModal","TimerPickerModalProps","TimerPickerModalRef","CustomTimerPickerModalStyles","TimerPicker","TimerPickerProps","TimerPickerRef","CustomTimerPickerStyles"],"sources":["index.ts"],"sourcesContent":["export {\n default as TimerPickerModal,\n TimerPickerModalProps,\n TimerPickerModalRef,\n CustomTimerPickerModalStyles,\n} from \"./components/TimerPickerModal\";\n\nexport {\n default as TimerPicker,\n TimerPickerProps,\n TimerPickerRef,\n CustomTimerPickerStyles,\n} from \"./components/TimerPicker\";\n"],"mappings":"AAAA,SACIA,OAAO,IAAIC,gBAAgB,EAC3BC,qBAAqB,EACrBC,mBAAmB,EACnBC,4BAA4B,QACzB,+BAA+B;AAEtC,SACIJ,OAAO,IAAIK,WAAW,EACtBC,gBAAgB,EAChBC,cAAc,EACdC,uBAAuB,QACpB,0BAA0B","ignoreList":[]}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render } from "@testing-library/react-native";
|
|
3
|
-
import DurationScroll from "../components/DurationScroll";
|
|
4
|
-
describe("DurationScroll", () => {
|
|
5
|
-
const onDurationChangeMock = jest.fn();
|
|
6
|
-
const emptyStyles = {
|
|
7
|
-
pickerContainer: {},
|
|
8
|
-
pickerLabelContainer: {},
|
|
9
|
-
pickerLabel: {},
|
|
10
|
-
pickerItemContainer: {},
|
|
11
|
-
pickerItem: {},
|
|
12
|
-
pickerAmPmContainer: {},
|
|
13
|
-
pickerAmPmLabel: {},
|
|
14
|
-
disabledPickerContainer: {},
|
|
15
|
-
disabledPickerItem: {},
|
|
16
|
-
pickerGradientOverlay: {}
|
|
17
|
-
};
|
|
18
|
-
it("renders without crashing", () => {
|
|
19
|
-
const {
|
|
20
|
-
getByTestId
|
|
21
|
-
} = render(/*#__PURE__*/React.createElement(DurationScroll, {
|
|
22
|
-
aggressivelyGetLatestDuration: false,
|
|
23
|
-
interval: 1,
|
|
24
|
-
maximumValue: 1,
|
|
25
|
-
onDurationChange: onDurationChangeMock,
|
|
26
|
-
padWithNItems: 0,
|
|
27
|
-
repeatNumbersNTimesNotExplicitlySet: true,
|
|
28
|
-
styles: emptyStyles,
|
|
29
|
-
testID: "duration-scroll"
|
|
30
|
-
}));
|
|
31
|
-
const component = getByTestId("duration-scroll");
|
|
32
|
-
expect(component).toBeDefined();
|
|
33
|
-
});
|
|
34
|
-
it("renders the correct number of items", () => {
|
|
35
|
-
const {
|
|
36
|
-
getAllByTestId
|
|
37
|
-
} = render(/*#__PURE__*/React.createElement(DurationScroll, {
|
|
38
|
-
aggressivelyGetLatestDuration: false,
|
|
39
|
-
interval: 1,
|
|
40
|
-
maximumValue: 23,
|
|
41
|
-
onDurationChange: onDurationChangeMock,
|
|
42
|
-
padWithNItems: 1,
|
|
43
|
-
repeatNumbersNTimesNotExplicitlySet: true,
|
|
44
|
-
styles: emptyStyles
|
|
45
|
-
}));
|
|
46
|
-
const items = getAllByTestId("picker-item");
|
|
47
|
-
expect(items).toHaveLength(10);
|
|
48
|
-
});
|
|
49
|
-
it("renders the label if provided", () => {
|
|
50
|
-
const {
|
|
51
|
-
getByText
|
|
52
|
-
} = render(/*#__PURE__*/React.createElement(DurationScroll, {
|
|
53
|
-
aggressivelyGetLatestDuration: false,
|
|
54
|
-
interval: 1,
|
|
55
|
-
label: "Duration",
|
|
56
|
-
maximumValue: 59,
|
|
57
|
-
onDurationChange: onDurationChangeMock,
|
|
58
|
-
padWithNItems: 1,
|
|
59
|
-
repeatNumbersNTimesNotExplicitlySet: true,
|
|
60
|
-
styles: emptyStyles
|
|
61
|
-
}));
|
|
62
|
-
const label = getByText("Duration");
|
|
63
|
-
expect(label).toBeDefined();
|
|
64
|
-
});
|
|
65
|
-
it("does not render label when not provided", () => {
|
|
66
|
-
const {
|
|
67
|
-
queryByTestId
|
|
68
|
-
} = render(/*#__PURE__*/React.createElement(DurationScroll, {
|
|
69
|
-
aggressivelyGetLatestDuration: false,
|
|
70
|
-
interval: 1,
|
|
71
|
-
maximumValue: 59,
|
|
72
|
-
onDurationChange: onDurationChangeMock,
|
|
73
|
-
padWithNItems: 1,
|
|
74
|
-
repeatNumbersNTimesNotExplicitlySet: true,
|
|
75
|
-
styles: emptyStyles
|
|
76
|
-
}));
|
|
77
|
-
const label = queryByTestId("picker-label");
|
|
78
|
-
expect(label).toBeNull();
|
|
79
|
-
});
|
|
80
|
-
it("handles different intervals", () => {
|
|
81
|
-
const {
|
|
82
|
-
getAllByTestId
|
|
83
|
-
} = render(/*#__PURE__*/React.createElement(DurationScroll, {
|
|
84
|
-
aggressivelyGetLatestDuration: false,
|
|
85
|
-
interval: 5,
|
|
86
|
-
maximumValue: 55,
|
|
87
|
-
onDurationChange: onDurationChangeMock,
|
|
88
|
-
padWithNItems: 1,
|
|
89
|
-
repeatNumbersNTimesNotExplicitlySet: true,
|
|
90
|
-
styles: emptyStyles
|
|
91
|
-
}));
|
|
92
|
-
const items = getAllByTestId("picker-item");
|
|
93
|
-
expect(items).toBeDefined();
|
|
94
|
-
});
|
|
95
|
-
it("renders with zero padWithNItems", () => {
|
|
96
|
-
const {
|
|
97
|
-
getByTestId
|
|
98
|
-
} = render(/*#__PURE__*/React.createElement(DurationScroll, {
|
|
99
|
-
aggressivelyGetLatestDuration: false,
|
|
100
|
-
interval: 1,
|
|
101
|
-
maximumValue: 59,
|
|
102
|
-
onDurationChange: onDurationChangeMock,
|
|
103
|
-
padWithNItems: 0,
|
|
104
|
-
repeatNumbersNTimesNotExplicitlySet: true,
|
|
105
|
-
styles: emptyStyles,
|
|
106
|
-
testID: "duration-scroll"
|
|
107
|
-
}));
|
|
108
|
-
const component = getByTestId("duration-scroll");
|
|
109
|
-
expect(component).toBeDefined();
|
|
110
|
-
});
|
|
111
|
-
it("handles large maximumValue", () => {
|
|
112
|
-
const {
|
|
113
|
-
getByTestId
|
|
114
|
-
} = render(/*#__PURE__*/React.createElement(DurationScroll, {
|
|
115
|
-
aggressivelyGetLatestDuration: false,
|
|
116
|
-
interval: 1,
|
|
117
|
-
maximumValue: 999,
|
|
118
|
-
onDurationChange: onDurationChangeMock,
|
|
119
|
-
padWithNItems: 1,
|
|
120
|
-
repeatNumbersNTimesNotExplicitlySet: true,
|
|
121
|
-
styles: emptyStyles,
|
|
122
|
-
testID: "duration-scroll"
|
|
123
|
-
}));
|
|
124
|
-
const component = getByTestId("duration-scroll");
|
|
125
|
-
expect(component).toBeDefined();
|
|
126
|
-
});
|
|
127
|
-
it("handles aggressivelyGetLatestDuration set to true", () => {
|
|
128
|
-
const {
|
|
129
|
-
getByTestId
|
|
130
|
-
} = render(/*#__PURE__*/React.createElement(DurationScroll, {
|
|
131
|
-
aggressivelyGetLatestDuration: true,
|
|
132
|
-
interval: 1,
|
|
133
|
-
maximumValue: 59,
|
|
134
|
-
onDurationChange: onDurationChangeMock,
|
|
135
|
-
padWithNItems: 1,
|
|
136
|
-
repeatNumbersNTimesNotExplicitlySet: true,
|
|
137
|
-
styles: emptyStyles,
|
|
138
|
-
testID: "duration-scroll"
|
|
139
|
-
}));
|
|
140
|
-
const component = getByTestId("duration-scroll");
|
|
141
|
-
expect(component).toBeDefined();
|
|
142
|
-
});
|
|
143
|
-
it("handles repeatNumbersNTimesNotExplicitlySet set to false", () => {
|
|
144
|
-
const {
|
|
145
|
-
getByTestId
|
|
146
|
-
} = render(/*#__PURE__*/React.createElement(DurationScroll, {
|
|
147
|
-
aggressivelyGetLatestDuration: false,
|
|
148
|
-
interval: 1,
|
|
149
|
-
maximumValue: 59,
|
|
150
|
-
onDurationChange: onDurationChangeMock,
|
|
151
|
-
padWithNItems: 1,
|
|
152
|
-
repeatNumbersNTimesNotExplicitlySet: false,
|
|
153
|
-
styles: emptyStyles,
|
|
154
|
-
testID: "duration-scroll"
|
|
155
|
-
}));
|
|
156
|
-
const component = getByTestId("duration-scroll");
|
|
157
|
-
expect(component).toBeDefined();
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
//# sourceMappingURL=DurationScroll.test.js.map
|