react-native-timer-picker 1.8.0 → 1.8.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 +6 -5
- package/dist/commonjs/components/TimerPickerModal/index.js +10 -8
- package/dist/commonjs/components/TimerPickerModal/index.js.map +1 -1
- package/dist/commonjs/components/TimerPickerModal/styles.js +2 -2
- package/dist/commonjs/components/TimerPickerModal/styles.js.map +1 -1
- package/dist/module/components/TimerPickerModal/index.js +10 -8
- package/dist/module/components/TimerPickerModal/index.js.map +1 -1
- package/dist/module/components/TimerPickerModal/styles.js +2 -2
- package/dist/module/components/TimerPickerModal/styles.js.map +1 -1
- package/package.json +1 -1
- package/src/components/TimerPickerModal/index.tsx +10 -7
- package/src/components/TimerPickerModal/styles.ts +4 -3
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ Includes iOS-style haptic and audio feedback 🍏
|
|
|
57
57
|
|
|
58
58
|
## Peer Dependencies 👶
|
|
59
59
|
|
|
60
|
-
This component will work in your React Native Project **
|
|
60
|
+
This component will work in your React Native Project **_without any peer dependencies_**.
|
|
61
61
|
|
|
62
62
|
### Linear Gradient
|
|
63
63
|
|
|
@@ -74,7 +74,7 @@ This is currently only supported on Expo with the [expo-haptics](https://www.npm
|
|
|
74
74
|
|
|
75
75
|
`import * as Haptics from "expo-haptics";`
|
|
76
76
|
|
|
77
|
-
**To enable
|
|
77
|
+
**To enable haptic feedback, you need to supply the imported `Haptics` namespace as a prop to either TimerPickerModal or TimerPicker.**
|
|
78
78
|
|
|
79
79
|
### Audio Feedback (Click Sound)
|
|
80
80
|
|
|
@@ -82,7 +82,7 @@ This is currently only supported on Expo with the [expo-av](https://www.npmjs.co
|
|
|
82
82
|
|
|
83
83
|
`import { Audio } from "expo-av";`
|
|
84
84
|
|
|
85
|
-
**To enable
|
|
85
|
+
**To enable audio feedback, you need to supply the imported `Audio` class as a prop to either TimerPickerModal or TimerPicker.**
|
|
86
86
|
|
|
87
87
|
<br>
|
|
88
88
|
|
|
@@ -394,8 +394,9 @@ return (
|
|
|
394
394
|
| pmLabel | Set the PM label if using the 12-hour picker | String | pm | false |
|
|
395
395
|
| disableInfiniteScroll | Disable the infinite scroll feature | Boolean | false | false |
|
|
396
396
|
| LinearGradient | Linear Gradient Component | [expo-linear-gradient](https://www.npmjs.com/package/expo-linear-gradient).LinearGradient or [react-native-linear-gradient](https://www.npmjs.com/package/react-native-linear-gradient).default | - | false |
|
|
397
|
-
|
|
|
398
|
-
|
|
|
397
|
+
| Haptics | Haptics Namespace (required for Haptic feedback) | [expo-haptics](https://www.npmjs.com/package/expo-haptics) | - | false |
|
|
398
|
+
| Audio | Audio Class (required for audio feedback i.e. click sound) | [expo-av](https://www.npmjs.com/package/expo-av).Audio | - | false |
|
|
399
|
+
| clickSoundAsset | Custom sound asset for click sound | require(.../somefolderpath) or {uri: www.someurl} | - | false |
|
|
399
400
|
| pickerContainerProps | Props for the picker container | `React.ComponentProps<typeof View>` | - | false |
|
|
400
401
|
| pickerGradientOverlayProps | Props for both gradient overlays | `Partial<LinearGradientProps>` | - | false |
|
|
401
402
|
| topPickerGradientOverlayProps | Props for the top gradient overlay | `Partial<LinearGradientProps>` | - | false |
|
|
@@ -17,12 +17,12 @@ const TimerPickerModal = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
17
17
|
const {
|
|
18
18
|
buttonContainerProps,
|
|
19
19
|
buttonTouchableOpacityProps,
|
|
20
|
-
cancelButtonText,
|
|
20
|
+
cancelButtonText = "Cancel",
|
|
21
21
|
closeOnOverlayPress,
|
|
22
|
-
confirmButtonText,
|
|
22
|
+
confirmButtonText = "Confirm",
|
|
23
23
|
containerProps,
|
|
24
24
|
contentContainerProps,
|
|
25
|
-
hideCancelButton,
|
|
25
|
+
hideCancelButton = false,
|
|
26
26
|
initialValue,
|
|
27
27
|
modalProps,
|
|
28
28
|
modalTitle,
|
|
@@ -118,16 +118,18 @@ const TimerPickerModal = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
118
118
|
ref: timerPickerRef,
|
|
119
119
|
initialValue: confirmedDuration
|
|
120
120
|
}, otherProps, {
|
|
121
|
-
|
|
121
|
+
aggressivelyGetLatestDuration: true,
|
|
122
|
+
onDurationChange: durationChangeHandler,
|
|
123
|
+
styles: customStyles
|
|
122
124
|
})), /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({}, buttonContainerProps, {
|
|
123
125
|
style: styles.buttonContainer
|
|
124
|
-
}), !hideCancelButton ? /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, _extends({
|
|
126
|
+
}), !hideCancelButton ? /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, _extends({}, buttonTouchableOpacityProps, {
|
|
125
127
|
onPress: cancelHandler
|
|
126
|
-
}
|
|
128
|
+
}), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
127
129
|
style: [styles.button, styles.cancelButton]
|
|
128
|
-
}, cancelButtonText)) : null, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, _extends({
|
|
130
|
+
}, cancelButtonText)) : null, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, _extends({}, buttonTouchableOpacityProps, {
|
|
129
131
|
onPress: confirmHandler
|
|
130
|
-
}
|
|
132
|
+
}), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
131
133
|
style: [styles.button, styles.confirmButton]
|
|
132
134
|
}, confirmButtonText))))));
|
|
133
135
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_Modal","_interopRequireDefault","_TimerPicker","_styles","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","TimerPickerModal","forwardRef","props","ref","buttonContainerProps","buttonTouchableOpacityProps","cancelButtonText","closeOnOverlayPress","confirmButtonText","containerProps","contentContainerProps","hideCancelButton","initialValue","modalProps","modalTitle","modalTitleProps","onCancel","onConfirm","onDurationChange","setIsVisible","styles","customStyles","visible","otherProps","generateStyles","timerPickerRef","useRef","safeInitialValue","hours","minutes","seconds","selectedDuration","setSelectedDuration","useState","confirmedDuration","setConfirmedDuration","reset","options","_timerPickerRef$curre","current","useEffect","hideModalHandler","confirmHandler","_timerPickerRef$curre2","_latestDuration$hours","_latestDuration$minut","_latestDuration$secon","latestDuration","newDuration","cancelHandler","durationChangeHandler","useCallback","duration","useImperativeHandle","_timerPickerRef$curre4","_timerPickerRef$curre5","_timerPickerRef$curre6","setValue","value","_timerPickerRef$curre3","createElement","isVisible","onOverlayPress","undefined","testID","View","style","container","contentContainer","Text","buttonContainer","TouchableOpacity","onPress","button","cancelButton","confirmButton","_default","exports","React","memo"],"sources":["index.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 Modal from \"../Modal\";\nimport TimerPicker from \"../TimerPicker\";\nimport type { TimerPickerRef } from \"../TimerPicker/types\";\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,\n closeOnOverlayPress,\n confirmButtonText,\n containerProps,\n contentContainerProps,\n hideCancelButton,\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\n const timerPickerRef = useRef<TimerPickerRef>(null);\n\n const safeInitialValue = {\n hours: initialValue?.hours ?? 0,\n minutes: initialValue?.minutes ?? 0,\n seconds: initialValue?.seconds ?? 0,\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.hours,\n safeInitialValue.minutes,\n safeInitialValue.seconds,\n ]);\n\n const hideModalHandler = () => {\n setSelectedDuration({\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 const newDuration = {\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: { hours: number; minutes: number; seconds: number }) => {\n setSelectedDuration(duration);\n onDurationChange?.(duration);\n },\n [onDurationChange]\n );\n\n useImperativeHandle(ref, () => ({\n reset,\n setValue: (value, options) => {\n setSelectedDuration(value);\n setConfirmedDuration(value);\n timerPickerRef.current?.setValue(value, options);\n },\n latestDuration: {\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 onDurationChange={durationChangeHandler}\n />\n <View\n {...buttonContainerProps}\n style={styles.buttonContainer}>\n {!hideCancelButton ? (\n <TouchableOpacity\n onPress={cancelHandler}\n {...buttonTouchableOpacityProps}>\n <Text\n style={[\n styles.button,\n styles.cancelButton,\n ]}>\n {cancelButtonText}\n </Text>\n </TouchableOpacity>\n ) : null}\n <TouchableOpacity\n onPress={confirmHandler}\n {...buttonTouchableOpacityProps}>\n <Text\n style={[\n styles.button,\n styles.confirmButton,\n ]}>\n {confirmButtonText}\n </Text>\n </TouchableOpacity>\n </View>\n </View>\n </View>\n </Modal>\n );\n }\n);\n\nexport default React.memo(TimerPickerModal);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AAGA,IAAAK,OAAA,GAAAL,OAAA;AAA0C,SAAAG,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBA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ChG,YAAA,CAAA2G,gBAAgB,EAAAhF,QAAA;IACbiF,OAAO,EAAEvB;EAAc,GACnB5C,2BAA2B,gBAC/B5C,MAAA,CAAAU,OAAA,CAAAyF,aAAA,CAAChG,YAAA,CAAAyG,IAAI;IACDH,KAAK,EAAE,CACH9C,MAAM,CAACqD,MAAM,EACbrD,MAAM,CAACsD,YAAY;EACrB,GACDpE,gBACC,CACQ,CAAC,GACnB,IAAI,eACR7C,MAAA,CAAAU,OAAA,CAAAyF,aAAA,CAAChG,YAAA,CAAA2G,gBAAgB,EAAAhF,QAAA;IACbiF,OAAO,EAAE9B;EAAe,GACpBrC,2BAA2B,gBAC/B5C,MAAA,CAAAU,OAAA,CAAAyF,aAAA,CAAChG,YAAA,CAAAyG,IAAI;IACDH,KAAK,EAAE,CACH9C,MAAM,CAACqD,MAAM,EACbrD,MAAM,CAACuD,aAAa;EACtB,GACDnE,iBACC,CACQ,CAChB,CACJ,CACJ,CACH,CAAC;AAEhB,CACJ,CAAC;AAAC,IAAAoE,QAAA,GAAAC,OAAA,CAAA1G,OAAA,gBAEa2G,cAAK,CAACC,IAAI,CAAC/E,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_Modal","_interopRequireDefault","_TimerPicker","_styles","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","_extends","assign","bind","target","arguments","length","source","key","apply","TimerPickerModal","forwardRef","props","ref","buttonContainerProps","buttonTouchableOpacityProps","cancelButtonText","closeOnOverlayPress","confirmButtonText","containerProps","contentContainerProps","hideCancelButton","initialValue","modalProps","modalTitle","modalTitleProps","onCancel","onConfirm","onDurationChange","setIsVisible","styles","customStyles","visible","otherProps","generateStyles","timerPickerRef","useRef","safeInitialValue","hours","minutes","seconds","selectedDuration","setSelectedDuration","useState","confirmedDuration","setConfirmedDuration","reset","options","_timerPickerRef$curre","current","useEffect","hideModalHandler","confirmHandler","_timerPickerRef$curre2","_latestDuration$hours","_latestDuration$minut","_latestDuration$secon","latestDuration","newDuration","cancelHandler","durationChangeHandler","useCallback","duration","useImperativeHandle","_timerPickerRef$curre4","_timerPickerRef$curre5","_timerPickerRef$curre6","setValue","value","_timerPickerRef$curre3","createElement","isVisible","onOverlayPress","undefined","testID","View","style","container","contentContainer","Text","aggressivelyGetLatestDuration","buttonContainer","TouchableOpacity","onPress","button","cancelButton","confirmButton","_default","exports","React","memo"],"sources":["index.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 Modal from \"../Modal\";\nimport TimerPicker from \"../TimerPicker\";\nimport type { TimerPickerRef } from \"../TimerPicker/types\";\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\n const timerPickerRef = useRef<TimerPickerRef>(null);\n\n const safeInitialValue = {\n hours: initialValue?.hours ?? 0,\n minutes: initialValue?.minutes ?? 0,\n seconds: initialValue?.seconds ?? 0,\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.hours,\n safeInitialValue.minutes,\n safeInitialValue.seconds,\n ]);\n\n const hideModalHandler = () => {\n setSelectedDuration({\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 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: { hours: number; minutes: number; seconds: number }) => {\n setSelectedDuration(duration);\n onDurationChange?.(duration);\n },\n [onDurationChange]\n );\n\n useImperativeHandle(ref, () => ({\n reset,\n setValue: (value, options) => {\n setSelectedDuration(value);\n setConfirmedDuration(value);\n timerPickerRef.current?.setValue(value, options);\n },\n latestDuration: {\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={customStyles}\n />\n <View\n {...buttonContainerProps}\n style={styles.buttonContainer}>\n {!hideCancelButton ? (\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 ) : null}\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 </View>\n </View>\n </View>\n </Modal>\n );\n }\n);\n\nexport default React.memo(TimerPickerModal);\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AASA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,YAAA,GAAAD,sBAAA,CAAAH,OAAA;AAGA,IAAAK,OAAA,GAAAL,OAAA;AAA0C,SAAAG,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,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O,EAAExB;EAAc,iBACvBxF,MAAA,CAAAU,OAAA,CAAAyF,aAAA,CAAChG,YAAA,CAAAyG,IAAI;IACDH,KAAK,EAAE,CACH9C,MAAM,CAACsD,MAAM,EACbtD,MAAM,CAACuD,YAAY;EACrB,GACDrE,gBACC,CACQ,CAAC,GACnB,IAAI,eACR7C,MAAA,CAAAU,OAAA,CAAAyF,aAAA,CAAChG,YAAA,CAAA4G,gBAAgB,EAAAjF,QAAA,KACTc,2BAA2B;IAC/BoE,OAAO,EAAE/B;EAAe,iBACxBjF,MAAA,CAAAU,OAAA,CAAAyF,aAAA,CAAChG,YAAA,CAAAyG,IAAI;IACDH,KAAK,EAAE,CACH9C,MAAM,CAACsD,MAAM,EACbtD,MAAM,CAACwD,aAAa;EACtB,GACDpE,iBACC,CACQ,CAChB,CACJ,CACJ,CACH,CAAC;AAEhB,CACJ,CAAC;AAAC,IAAAqE,QAAA,GAAAC,OAAA,CAAA3G,OAAA,gBAEa4G,cAAK,CAACC,IAAI,CAAChF,gBAAgB,CAAC"}
|
|
@@ -17,7 +17,7 @@ const generateStyles = customStyles => _reactNative.StyleSheet.create({
|
|
|
17
17
|
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.container)
|
|
18
18
|
},
|
|
19
19
|
contentContainer: {
|
|
20
|
-
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,
|
|
20
|
+
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),
|
|
21
21
|
justifyContent: "center",
|
|
22
22
|
alignItems: "center",
|
|
23
23
|
borderRadius: 20,
|
|
@@ -56,7 +56,7 @@ const generateStyles = customStyles => _reactNative.StyleSheet.create({
|
|
|
56
56
|
},
|
|
57
57
|
modalTitle: {
|
|
58
58
|
fontSize: 24,
|
|
59
|
-
fontWeight: "
|
|
59
|
+
fontWeight: "600",
|
|
60
60
|
marginBottom: 15,
|
|
61
61
|
color: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? DARK_MODE_TEXT_COLOR : LIGHT_MODE_TEXT_COLOR,
|
|
62
62
|
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.text),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","DARK_MODE_BACKGROUND_COLOR","DARK_MODE_TEXT_COLOR","LIGHT_MODE_BACKGROUND_COLOR","LIGHT_MODE_TEXT_COLOR","generateStyles","customStyles","StyleSheet","create","container","justifyContent","alignItems","overflow","contentContainer","backgroundColor","theme","borderRadius","padding","buttonContainer","flexDirection","marginTop","button","marginHorizontal","paddingVertical","paddingHorizontal","borderWidth","fontSize","text","cancelButton","borderColor","color","undefined","confirmButton","modalTitle","fontWeight","marginBottom","exports"],"sources":["styles.ts"],"sourcesContent":["import { StyleSheet } from \"react-native\";\nimport type { 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) =>\n StyleSheet.create({\n container: {\n justifyContent: \"center\",\n alignItems: \"center\",\n overflow: \"hidden\",\n ...customStyles?.container,\n },\n contentContainer: {\n backgroundColor:\n customStyles?.backgroundColor
|
|
1
|
+
{"version":3,"names":["_reactNative","require","DARK_MODE_BACKGROUND_COLOR","DARK_MODE_TEXT_COLOR","LIGHT_MODE_BACKGROUND_COLOR","LIGHT_MODE_TEXT_COLOR","generateStyles","customStyles","StyleSheet","create","container","justifyContent","alignItems","overflow","contentContainer","backgroundColor","theme","borderRadius","padding","buttonContainer","flexDirection","marginTop","button","marginHorizontal","paddingVertical","paddingHorizontal","borderWidth","fontSize","text","cancelButton","borderColor","color","undefined","confirmButton","modalTitle","fontWeight","marginBottom","exports"],"sources":["styles.ts"],"sourcesContent":["import { StyleSheet } from \"react-native\";\nimport type { 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) =>\n StyleSheet.create({\n container: {\n justifyContent: \"center\",\n alignItems: \"center\",\n overflow: \"hidden\",\n ...customStyles?.container,\n },\n contentContainer: {\n backgroundColor:\n customStyles?.backgroundColor ??\n (customStyles?.theme === \"dark\"\n ? DARK_MODE_BACKGROUND_COLOR\n : LIGHT_MODE_BACKGROUND_COLOR),\n justifyContent: \"center\",\n alignItems: \"center\",\n borderRadius: 20,\n padding: 20,\n ...customStyles?.contentContainer,\n },\n buttonContainer: {\n flexDirection: \"row\",\n marginTop: 25,\n ...customStyles?.buttonContainer,\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 ...customStyles?.text,\n ...customStyles?.button,\n },\n cancelButton: {\n borderColor: \"gray\",\n color:\n customStyles?.theme === \"dark\" ? DARK_MODE_TEXT_COLOR : \"gray\",\n backgroundColor:\n customStyles?.theme === \"dark\" ? \"gray\" : undefined,\n ...customStyles?.text,\n ...customStyles?.cancelButton,\n },\n confirmButton: {\n borderColor: \"green\",\n color:\n customStyles?.theme === \"dark\" ? DARK_MODE_TEXT_COLOR : \"green\",\n backgroundColor:\n customStyles?.theme === \"dark\" ? \"green\" : undefined,\n ...customStyles?.text,\n ...customStyles?.confirmButton,\n },\n modalTitle: {\n fontSize: 24,\n fontWeight: \"600\",\n marginBottom: 15,\n color:\n customStyles?.theme === \"dark\"\n ? DARK_MODE_TEXT_COLOR\n : LIGHT_MODE_TEXT_COLOR,\n ...customStyles?.text,\n ...customStyles?.modalTitle,\n },\n });\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAeA,MAAMC,0BAA0B,GAAG,SAAS;AAC5C,MAAMC,oBAAoB,GAAG,SAAS;AACtC,MAAMC,2BAA2B,GAAG,SAAS;AAC7C,MAAMC,qBAAqB,GAAG,SAAS;AAEhC,MAAMC,cAAc,GACvBC,YAAsD,IAEtDC,uBAAU,CAACC,MAAM,CAAC;EACdC,SAAS,EAAE;IACPC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE,QAAQ;IACpBC,QAAQ,EAAE,QAAQ;IAClB,IAAGN,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEG,SAAS;EAC9B,CAAC;EACDI,gBAAgB,EAAE;IACdC,eAAe,EACX,CAAAR,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEQ,eAAe,MAC5B,CAAAR,YAAY,aAAZA,YAAY,uBAAZA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AK,MAAK,MAAM,GAAGb,oBAAoB,GAAG,OAAO;IACnEY,eAAe,EACX,CAAAR,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAES,KAAK,MAAK,MAAM,GAAG,OAAO,GAAGgB,SAAS;IACxD,IAAGzB,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEqB,IAAI;IACrB,IAAGrB,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAE0B,aAAa;EAClC,CAAC;EACDC,UAAU,EAAE;IACRP,QAAQ,EAAE,EAAE;IACZQ,UAAU,EAAE,KAAK;IACjBC,YAAY,EAAE,EAAE;IAChBL,KAAK,EACD,CAAAxB,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAES,KAAK,MAAK,MAAM,GACxBb,oBAAoB,GACpBE,qBAAqB;IAC/B,IAAGE,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEqB,IAAI;IACrB,IAAGrB,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAE2B,UAAU;EAC/B;AACJ,CAAC,CAAC;AAACG,OAAA,CAAA/B,cAAA,GAAAA,cAAA"}
|
|
@@ -8,12 +8,12 @@ const TimerPickerModal = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
8
8
|
const {
|
|
9
9
|
buttonContainerProps,
|
|
10
10
|
buttonTouchableOpacityProps,
|
|
11
|
-
cancelButtonText,
|
|
11
|
+
cancelButtonText = "Cancel",
|
|
12
12
|
closeOnOverlayPress,
|
|
13
|
-
confirmButtonText,
|
|
13
|
+
confirmButtonText = "Confirm",
|
|
14
14
|
containerProps,
|
|
15
15
|
contentContainerProps,
|
|
16
|
-
hideCancelButton,
|
|
16
|
+
hideCancelButton = false,
|
|
17
17
|
initialValue,
|
|
18
18
|
modalProps,
|
|
19
19
|
modalTitle,
|
|
@@ -109,16 +109,18 @@ const TimerPickerModal = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
109
109
|
ref: timerPickerRef,
|
|
110
110
|
initialValue: confirmedDuration
|
|
111
111
|
}, otherProps, {
|
|
112
|
-
|
|
112
|
+
aggressivelyGetLatestDuration: true,
|
|
113
|
+
onDurationChange: durationChangeHandler,
|
|
114
|
+
styles: customStyles
|
|
113
115
|
})), /*#__PURE__*/React.createElement(View, _extends({}, buttonContainerProps, {
|
|
114
116
|
style: styles.buttonContainer
|
|
115
|
-
}), !hideCancelButton ? /*#__PURE__*/React.createElement(TouchableOpacity, _extends({
|
|
117
|
+
}), !hideCancelButton ? /*#__PURE__*/React.createElement(TouchableOpacity, _extends({}, buttonTouchableOpacityProps, {
|
|
116
118
|
onPress: cancelHandler
|
|
117
|
-
}
|
|
119
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
118
120
|
style: [styles.button, styles.cancelButton]
|
|
119
|
-
}, cancelButtonText)) : null, /*#__PURE__*/React.createElement(TouchableOpacity, _extends({
|
|
121
|
+
}, cancelButtonText)) : null, /*#__PURE__*/React.createElement(TouchableOpacity, _extends({}, buttonTouchableOpacityProps, {
|
|
120
122
|
onPress: confirmHandler
|
|
121
|
-
}
|
|
123
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
122
124
|
style: [styles.button, styles.confirmButton]
|
|
123
125
|
}, confirmButtonText))))));
|
|
124
126
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","View","Text","TouchableOpacity","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","timerPickerRef","safeInitialValue","hours","minutes","seconds","selectedDuration","setSelectedDuration","confirmedDuration","setConfirmedDuration","reset","options","_timerPickerRef$curre","current","hideModalHandler","confirmHandler","_timerPickerRef$curre2","_latestDuration$hours","_latestDuration$minut","_latestDuration$secon","latestDuration","newDuration","cancelHandler","durationChangeHandler","duration","_timerPickerRef$curre4","_timerPickerRef$curre5","_timerPickerRef$curre6","setValue","value","_timerPickerRef$curre3","createElement","_extends","isVisible","onOverlayPress","undefined","testID","style","container","contentContainer","buttonContainer","onPress","button","cancelButton","confirmButton","memo"],"sources":["index.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 Modal from \"../Modal\";\nimport TimerPicker from \"../TimerPicker\";\nimport type { TimerPickerRef } from \"../TimerPicker/types\";\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,\n closeOnOverlayPress,\n confirmButtonText,\n containerProps,\n contentContainerProps,\n hideCancelButton,\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\n const timerPickerRef = useRef<TimerPickerRef>(null);\n\n const safeInitialValue = {\n hours: initialValue?.hours ?? 0,\n minutes: initialValue?.minutes ?? 0,\n seconds: initialValue?.seconds ?? 0,\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.hours,\n safeInitialValue.minutes,\n safeInitialValue.seconds,\n ]);\n\n const hideModalHandler = () => {\n setSelectedDuration({\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 const newDuration = {\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: { hours: number; minutes: number; seconds: number }) => {\n setSelectedDuration(duration);\n onDurationChange?.(duration);\n },\n [onDurationChange]\n );\n\n useImperativeHandle(ref, () => ({\n reset,\n setValue: (value, options) => {\n setSelectedDuration(value);\n setConfirmedDuration(value);\n timerPickerRef.current?.setValue(value, options);\n },\n latestDuration: {\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 onDurationChange={durationChangeHandler}\n />\n <View\n {...buttonContainerProps}\n style={styles.buttonContainer}>\n {!hideCancelButton ? (\n <TouchableOpacity\n onPress={cancelHandler}\n {...buttonTouchableOpacityProps}>\n <Text\n style={[\n styles.button,\n styles.cancelButton,\n ]}>\n {cancelButtonText}\n </Text>\n </TouchableOpacity>\n ) : null}\n <TouchableOpacity\n onPress={confirmHandler}\n {...buttonTouchableOpacityProps}>\n <Text\n style={[\n styles.button,\n styles.confirmButton,\n ]}>\n {confirmButtonText}\n </Text>\n </TouchableOpacity>\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,IAAI,EAAEC,IAAI,EAAEC,gBAAgB,QAAQ,cAAc;AAE3D,OAAOC,KAAK,MAAM,UAAU;AAC5B,OAAOC,WAAW,MAAM,gBAAgB;AAGxC,SAASC,cAAc,QAAQ,UAAU;AAGzC,MAAMC,gBAAgB,gBAAGZ,UAAU,CAC/B,CAACa,KAAK,EAAEC,GAAG,KAAK;EACZ,MAAM;IACFC,oBAAoB;IACpBC,2BAA2B;IAC3BC,gBAAgB;IAChBC,mBAAmB;IACnBC,iBAAiB;IACjBC,cAAc;IACdC,qBAAqB;IACrBC,gBAAgB;IAChBC,YAAY;IACZC,UAAU;IACVC,UAAU;IACVC,eAAe;IACfC,QAAQ;IACRC,SAAS;IACTC,gBAAgB;IAChBC,YAAY;IACZC,MAAM,EAAEC,YAAY;IACpBC,OAAO;IACP,GAAGC;EACP,CAAC,GAAGrB,KAAK;EAET,MAAMkB,MAAM,GAAGpB,cAAc,CAACqB,YAAY,CAAC;EAE3C,MAAMG,cAAc,GAAG/B,MAAM,CAAiB,IAAI,CAAC;EAEnD,MAAMgC,gBAAgB,GAAG;IACrBC,KAAK,EAAE,CAAAd,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEc,KAAK,KAAI,CAAC;IAC/BC,OAAO,EAAE,CAAAf,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEe,OAAO,KAAI,CAAC;IACnC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AW,EAAAwD,QAAA;IACRpD,GAAG,EAAEqB,cAAe;IACpBZ,YAAY,EAAEmB;EAAkB,GAC5BR,UAAU;IACdL,gBAAgB,EAAE4B;EAAsB,EAC3C,CAAC,eACF1D,KAAA,CAAAkE,aAAA,CAAC3D,IAAI,EAAA4D,QAAA,KACGnD,oBAAoB;IACxBwD,KAAK,EAAExC,MAAM,CAAC2C;EAAgB,IAC7B,CAACpD,gBAAgB,gBACdvB,KAAA,CAAAkE,aAAA,CAACzD,gBAAgB,EAAA0D,QAAA;IACbS,OAAO,EAAEnB;EAAc,GACnBxC,2BAA2B,gBAC/BjB,KAAA,CAAAkE,aAAA,CAAC1D,IAAI;IACDgE,KAAK,EAAE,CACHxC,MAAM,CAAC6C,MAAM,EACb7C,MAAM,CAAC8C,YAAY;EACrB,GACD5D,gBACC,CACQ,CAAC,GACnB,IAAI,eACRlB,KAAA,CAAAkE,aAAA,CAACzD,gBAAgB,EAAA0D,QAAA;IACbS,OAAO,EAAE1B;EAAe,GACpBjC,2BAA2B,gBAC/BjB,KAAA,CAAAkE,aAAA,CAAC1D,IAAI;IACDgE,KAAK,EAAE,CACHxC,MAAM,CAAC6C,MAAM,EACb7C,MAAM,CAAC+C,aAAa;EACtB,GACD3D,iBACC,CACQ,CAChB,CACJ,CACJ,CACH,CAAC;AAEhB,CACJ,CAAC;AAED,4BAAepB,KAAK,CAACgF,IAAI,CAACnE,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"names":["React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","View","Text","TouchableOpacity","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","timerPickerRef","safeInitialValue","hours","minutes","seconds","selectedDuration","setSelectedDuration","confirmedDuration","setConfirmedDuration","reset","options","_timerPickerRef$curre","current","hideModalHandler","confirmHandler","_timerPickerRef$curre2","_latestDuration$hours","_latestDuration$minut","_latestDuration$secon","latestDuration","newDuration","cancelHandler","durationChangeHandler","duration","_timerPickerRef$curre4","_timerPickerRef$curre5","_timerPickerRef$curre6","setValue","value","_timerPickerRef$curre3","createElement","_extends","isVisible","onOverlayPress","undefined","testID","style","container","contentContainer","aggressivelyGetLatestDuration","buttonContainer","onPress","button","cancelButton","confirmButton","memo"],"sources":["index.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 Modal from \"../Modal\";\nimport TimerPicker from \"../TimerPicker\";\nimport type { TimerPickerRef } from \"../TimerPicker/types\";\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\n const timerPickerRef = useRef<TimerPickerRef>(null);\n\n const safeInitialValue = {\n hours: initialValue?.hours ?? 0,\n minutes: initialValue?.minutes ?? 0,\n seconds: initialValue?.seconds ?? 0,\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.hours,\n safeInitialValue.minutes,\n safeInitialValue.seconds,\n ]);\n\n const hideModalHandler = () => {\n setSelectedDuration({\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 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: { hours: number; minutes: number; seconds: number }) => {\n setSelectedDuration(duration);\n onDurationChange?.(duration);\n },\n [onDurationChange]\n );\n\n useImperativeHandle(ref, () => ({\n reset,\n setValue: (value, options) => {\n setSelectedDuration(value);\n setConfirmedDuration(value);\n timerPickerRef.current?.setValue(value, options);\n },\n latestDuration: {\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={customStyles}\n />\n <View\n {...buttonContainerProps}\n style={styles.buttonContainer}>\n {!hideCancelButton ? (\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 ) : null}\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 </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,IAAI,EAAEC,IAAI,EAAEC,gBAAgB,QAAQ,cAAc;AAE3D,OAAOC,KAAK,MAAM,UAAU;AAC5B,OAAOC,WAAW,MAAM,gBAAgB;AAGxC,SAASC,cAAc,QAAQ,UAAU;AAGzC,MAAMC,gBAAgB,gBAAGZ,UAAU,CAC/B,CAACa,KAAK,EAAEC,GAAG,KAAK;EACZ,MAAM;IACFC,oBAAoB;IACpBC,2BAA2B;IAC3BC,gBAAgB,GAAG,QAAQ;IAC3BC,mBAAmB;IACnBC,iBAAiB,GAAG,SAAS;IAC7BC,cAAc;IACdC,qBAAqB;IACrBC,gBAAgB,GAAG,KAAK;IACxBC,YAAY;IACZC,UAAU;IACVC,UAAU;IACVC,eAAe;IACfC,QAAQ;IACRC,SAAS;IACTC,gBAAgB;IAChBC,YAAY;IACZC,MAAM,EAAEC,YAAY;IACpBC,OAAO;IACP,GAAGC;EACP,CAAC,GAAGrB,KAAK;EAET,MAAMkB,MAAM,GAAGpB,cAAc,CAACqB,YAAY,CAAC;EAE3C,MAAMG,cAAc,GAAG/B,MAAM,CAAiB,IAAI,CA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M,CAAC0C;EAAiB,IAC9BhD,UAAU,gBACP1B,KAAA,CAAAkE,aAAA,CAAC1D,IAAI,EAAA2D,QAAA,KACGxC,eAAe;IACnB6C,KAAK,EAAExC,MAAM,CAACN;EAAW,IACxBA,UACC,CAAC,GACP,IAAI,eACR1B,KAAA,CAAAkE,aAAA,CAACvD,WAAW,EAAAwD,QAAA;IACRpD,GAAG,EAAEqB,cAAe;IACpBZ,YAAY,EAAEmB;EAAkB,GAC5BR,UAAU;IACdwC,6BAA6B;IAC7B7C,gBAAgB,EAAE4B,qBAAsB;IACxC1B,MAAM,EAAEC;EAAa,EACxB,CAAC,eACFjC,KAAA,CAAAkE,aAAA,CAAC3D,IAAI,EAAA4D,QAAA,KACGnD,oBAAoB;IACxBwD,KAAK,EAAExC,MAAM,CAAC4C;EAAgB,IAC7B,CAACrD,gBAAgB,gBACdvB,KAAA,CAAAkE,aAAA,CAACzD,gBAAgB,EAAA0D,QAAA,KACTlD,2BAA2B;IAC/B4D,OAAO,EAAEpB;EAAc,iBACvBzD,KAAA,CAAAkE,aAAA,CAAC1D,IAAI;IACDgE,KAAK,EAAE,CACHxC,MAAM,CAAC8C,MAAM,EACb9C,MAAM,CAAC+C,YAAY;EACrB,GACD7D,gBACC,CACQ,CAAC,GACnB,IAAI,eACRlB,KAAA,CAAAkE,aAAA,CAACzD,gBAAgB,EAAA0D,QAAA,KACTlD,2BAA2B;IAC/B4D,OAAO,EAAE3B;EAAe,iBACxBlD,KAAA,CAAAkE,aAAA,CAAC1D,IAAI;IACDgE,KAAK,EAAE,CACHxC,MAAM,CAAC8C,MAAM,EACb9C,MAAM,CAACgD,aAAa;EACtB,GACD5D,iBACC,CACQ,CAChB,CACJ,CACJ,CACH,CAAC;AAEhB,CACJ,CAAC;AAED,4BAAepB,KAAK,CAACiF,IAAI,CAACpE,gBAAgB,CAAC"}
|
|
@@ -11,7 +11,7 @@ export const generateStyles = customStyles => StyleSheet.create({
|
|
|
11
11
|
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.container)
|
|
12
12
|
},
|
|
13
13
|
contentContainer: {
|
|
14
|
-
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,
|
|
14
|
+
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),
|
|
15
15
|
justifyContent: "center",
|
|
16
16
|
alignItems: "center",
|
|
17
17
|
borderRadius: 20,
|
|
@@ -50,7 +50,7 @@ export const generateStyles = customStyles => StyleSheet.create({
|
|
|
50
50
|
},
|
|
51
51
|
modalTitle: {
|
|
52
52
|
fontSize: 24,
|
|
53
|
-
fontWeight: "
|
|
53
|
+
fontWeight: "600",
|
|
54
54
|
marginBottom: 15,
|
|
55
55
|
color: (customStyles === null || customStyles === void 0 ? void 0 : customStyles.theme) === "dark" ? DARK_MODE_TEXT_COLOR : LIGHT_MODE_TEXT_COLOR,
|
|
56
56
|
...(customStyles === null || customStyles === void 0 ? void 0 : customStyles.text),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","DARK_MODE_BACKGROUND_COLOR","DARK_MODE_TEXT_COLOR","LIGHT_MODE_BACKGROUND_COLOR","LIGHT_MODE_TEXT_COLOR","generateStyles","customStyles","create","container","justifyContent","alignItems","overflow","contentContainer","backgroundColor","theme","borderRadius","padding","buttonContainer","flexDirection","marginTop","button","marginHorizontal","paddingVertical","paddingHorizontal","borderWidth","fontSize","text","cancelButton","borderColor","color","undefined","confirmButton","modalTitle","fontWeight","marginBottom"],"sources":["styles.ts"],"sourcesContent":["import { StyleSheet } from \"react-native\";\nimport type { 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) =>\n StyleSheet.create({\n container: {\n justifyContent: \"center\",\n alignItems: \"center\",\n overflow: \"hidden\",\n ...customStyles?.container,\n },\n contentContainer: {\n backgroundColor:\n customStyles?.backgroundColor
|
|
1
|
+
{"version":3,"names":["StyleSheet","DARK_MODE_BACKGROUND_COLOR","DARK_MODE_TEXT_COLOR","LIGHT_MODE_BACKGROUND_COLOR","LIGHT_MODE_TEXT_COLOR","generateStyles","customStyles","create","container","justifyContent","alignItems","overflow","contentContainer","backgroundColor","theme","borderRadius","padding","buttonContainer","flexDirection","marginTop","button","marginHorizontal","paddingVertical","paddingHorizontal","borderWidth","fontSize","text","cancelButton","borderColor","color","undefined","confirmButton","modalTitle","fontWeight","marginBottom"],"sources":["styles.ts"],"sourcesContent":["import { StyleSheet } from \"react-native\";\nimport type { 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) =>\n StyleSheet.create({\n container: {\n justifyContent: \"center\",\n alignItems: \"center\",\n overflow: \"hidden\",\n ...customStyles?.container,\n },\n contentContainer: {\n backgroundColor:\n customStyles?.backgroundColor ??\n (customStyles?.theme === \"dark\"\n ? DARK_MODE_BACKGROUND_COLOR\n : LIGHT_MODE_BACKGROUND_COLOR),\n justifyContent: \"center\",\n alignItems: \"center\",\n borderRadius: 20,\n padding: 20,\n ...customStyles?.contentContainer,\n },\n buttonContainer: {\n flexDirection: \"row\",\n marginTop: 25,\n ...customStyles?.buttonContainer,\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 ...customStyles?.text,\n ...customStyles?.button,\n },\n cancelButton: {\n borderColor: \"gray\",\n color:\n customStyles?.theme === \"dark\" ? DARK_MODE_TEXT_COLOR : \"gray\",\n backgroundColor:\n customStyles?.theme === \"dark\" ? \"gray\" : undefined,\n ...customStyles?.text,\n ...customStyles?.cancelButton,\n },\n confirmButton: {\n borderColor: \"green\",\n color:\n customStyles?.theme === \"dark\" ? DARK_MODE_TEXT_COLOR : \"green\",\n backgroundColor:\n customStyles?.theme === \"dark\" ? \"green\" : undefined,\n ...customStyles?.text,\n ...customStyles?.confirmButton,\n },\n modalTitle: {\n fontSize: 24,\n fontWeight: \"600\",\n marginBottom: 15,\n color:\n customStyles?.theme === \"dark\"\n ? DARK_MODE_TEXT_COLOR\n : LIGHT_MODE_TEXT_COLOR,\n ...customStyles?.text,\n ...customStyles?.modalTitle,\n },\n });\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAezC,MAAMC,0BAA0B,GAAG,SAAS;AAC5C,MAAMC,oBAAo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{
|
|
22
22
|
buttonContainerProps,
|
|
23
23
|
buttonTouchableOpacityProps,
|
|
24
|
-
cancelButtonText,
|
|
24
|
+
cancelButtonText = "Cancel",
|
|
25
25
|
closeOnOverlayPress,
|
|
26
|
-
confirmButtonText,
|
|
26
|
+
confirmButtonText = "Confirm",
|
|
27
27
|
containerProps,
|
|
28
28
|
contentContainerProps,
|
|
29
|
-
hideCancelButton,
|
|
29
|
+
hideCancelButton = false,
|
|
30
30
|
initialValue,
|
|
31
31
|
modalProps,
|
|
32
32
|
modalTitle,
|
|
@@ -82,6 +82,7 @@ const TimerPickerModal = forwardRef<TimerPickerModalRef, TimerPickerModalProps>(
|
|
|
82
82
|
|
|
83
83
|
const confirmHandler = () => {
|
|
84
84
|
const latestDuration = timerPickerRef.current?.latestDuration;
|
|
85
|
+
|
|
85
86
|
const newDuration = {
|
|
86
87
|
hours: latestDuration?.hours?.current ?? selectedDuration.hours,
|
|
87
88
|
minutes:
|
|
@@ -147,15 +148,17 @@ const TimerPickerModal = forwardRef<TimerPickerModalRef, TimerPickerModalProps>(
|
|
|
147
148
|
ref={timerPickerRef}
|
|
148
149
|
initialValue={confirmedDuration}
|
|
149
150
|
{...otherProps}
|
|
151
|
+
aggressivelyGetLatestDuration
|
|
150
152
|
onDurationChange={durationChangeHandler}
|
|
153
|
+
styles={customStyles}
|
|
151
154
|
/>
|
|
152
155
|
<View
|
|
153
156
|
{...buttonContainerProps}
|
|
154
157
|
style={styles.buttonContainer}>
|
|
155
158
|
{!hideCancelButton ? (
|
|
156
159
|
<TouchableOpacity
|
|
157
|
-
|
|
158
|
-
{
|
|
160
|
+
{...buttonTouchableOpacityProps}
|
|
161
|
+
onPress={cancelHandler}>
|
|
159
162
|
<Text
|
|
160
163
|
style={[
|
|
161
164
|
styles.button,
|
|
@@ -166,8 +169,8 @@ const TimerPickerModal = forwardRef<TimerPickerModalRef, TimerPickerModalProps>(
|
|
|
166
169
|
</TouchableOpacity>
|
|
167
170
|
) : null}
|
|
168
171
|
<TouchableOpacity
|
|
169
|
-
|
|
170
|
-
{
|
|
172
|
+
{...buttonTouchableOpacityProps}
|
|
173
|
+
onPress={confirmHandler}>
|
|
171
174
|
<Text
|
|
172
175
|
style={[
|
|
173
176
|
styles.button,
|
|
@@ -30,9 +30,10 @@ export const generateStyles = (
|
|
|
30
30
|
},
|
|
31
31
|
contentContainer: {
|
|
32
32
|
backgroundColor:
|
|
33
|
-
customStyles?.backgroundColor ??
|
|
33
|
+
customStyles?.backgroundColor ??
|
|
34
|
+
(customStyles?.theme === "dark"
|
|
34
35
|
? DARK_MODE_BACKGROUND_COLOR
|
|
35
|
-
: LIGHT_MODE_BACKGROUND_COLOR,
|
|
36
|
+
: LIGHT_MODE_BACKGROUND_COLOR),
|
|
36
37
|
justifyContent: "center",
|
|
37
38
|
alignItems: "center",
|
|
38
39
|
borderRadius: 20,
|
|
@@ -75,7 +76,7 @@ export const generateStyles = (
|
|
|
75
76
|
},
|
|
76
77
|
modalTitle: {
|
|
77
78
|
fontSize: 24,
|
|
78
|
-
fontWeight: "
|
|
79
|
+
fontWeight: "600",
|
|
79
80
|
marginBottom: 15,
|
|
80
81
|
color:
|
|
81
82
|
customStyles?.theme === "dark"
|