react-native-timer-picker 2.1.0 → 2.2.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 +227 -152
- package/dist/commonjs/components/DurationScroll/DurationScroll.js +417 -0
- package/dist/commonjs/components/DurationScroll/DurationScroll.js.map +1 -0
- package/dist/commonjs/components/DurationScroll/index.js +20 -392
- package/dist/commonjs/components/DurationScroll/index.js.map +1 -1
- package/dist/commonjs/components/DurationScroll/types.js.map +1 -1
- package/dist/commonjs/components/Modal/Modal.js +107 -0
- package/dist/commonjs/components/Modal/Modal.js.map +1 -0
- package/dist/commonjs/components/Modal/index.js +20 -101
- package/dist/commonjs/components/Modal/index.js.map +1 -1
- package/dist/commonjs/components/TimerPicker/TimerPicker.js +225 -0
- package/dist/commonjs/components/TimerPicker/TimerPicker.js.map +1 -0
- package/dist/commonjs/components/TimerPicker/index.js +29 -166
- package/dist/commonjs/components/TimerPicker/index.js.map +1 -1
- package/dist/commonjs/components/TimerPicker/styles.js +1 -1
- package/dist/commonjs/components/TimerPicker/styles.js.map +1 -1
- package/dist/commonjs/components/TimerPicker/types.js.map +1 -1
- package/dist/commonjs/components/TimerPickerModal/TimerPickerModal.js +143 -0
- package/dist/commonjs/components/TimerPickerModal/TimerPickerModal.js.map +1 -0
- package/dist/commonjs/components/TimerPickerModal/index.js +30 -131
- package/dist/commonjs/components/TimerPickerModal/index.js.map +1 -1
- package/dist/commonjs/components/TimerPickerModal/types.js.map +1 -1
- package/dist/commonjs/index.js +9 -13
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/tests/TimerPicker.test.js +4 -1
- package/dist/commonjs/tests/TimerPicker.test.js.map +1 -1
- package/dist/commonjs/utils/colorToRgba.js +35 -4
- package/dist/commonjs/utils/colorToRgba.js.map +1 -1
- package/dist/commonjs/utils/generateNumbers.js +67 -0
- package/dist/commonjs/utils/generateNumbers.js.map +1 -1
- package/dist/commonjs/utils/getAdjustedLimit.js +25 -0
- package/dist/commonjs/utils/getAdjustedLimit.js.map +1 -1
- package/dist/commonjs/utils/getDurationAndIndexFromScrollOffset.js +38 -0
- package/dist/commonjs/utils/getDurationAndIndexFromScrollOffset.js.map +1 -1
- package/dist/commonjs/utils/getInitialScrollIndex.js +38 -0
- package/dist/commonjs/utils/getInitialScrollIndex.js.map +1 -1
- package/dist/commonjs/utils/getSafeInitialValue.js +28 -0
- package/dist/commonjs/utils/getSafeInitialValue.js.map +1 -1
- package/dist/commonjs/utils/padNumber.js +25 -0
- package/dist/commonjs/utils/padNumber.js.map +1 -1
- package/dist/module/components/DurationScroll/DurationScroll.js +410 -0
- package/dist/module/components/DurationScroll/DurationScroll.js.map +1 -0
- package/dist/module/components/DurationScroll/index.js +2 -390
- package/dist/module/components/DurationScroll/index.js.map +1 -1
- package/dist/module/components/DurationScroll/types.js.map +1 -1
- package/dist/module/components/Modal/Modal.js +99 -0
- package/dist/module/components/Modal/Modal.js.map +1 -0
- package/dist/module/components/Modal/index.js +2 -98
- package/dist/module/components/Modal/index.js.map +1 -1
- package/dist/module/components/TimerPicker/TimerPicker.js +217 -0
- package/dist/module/components/TimerPicker/TimerPicker.js.map +1 -0
- package/dist/module/components/TimerPicker/index.js +3 -166
- package/dist/module/components/TimerPicker/index.js.map +1 -1
- package/dist/module/components/TimerPicker/styles.js +1 -1
- package/dist/module/components/TimerPicker/styles.js.map +1 -1
- package/dist/module/components/TimerPicker/types.js.map +1 -1
- package/dist/module/components/TimerPickerModal/TimerPickerModal.js +135 -0
- package/dist/module/components/TimerPickerModal/TimerPickerModal.js.map +1 -0
- package/dist/module/components/TimerPickerModal/index.js +3 -130
- package/dist/module/components/TimerPickerModal/index.js.map +1 -1
- package/dist/module/components/TimerPickerModal/types.js.map +1 -1
- package/dist/module/index.js +2 -6
- package/dist/module/index.js.map +1 -1
- package/dist/module/tests/TimerPicker.test.js +4 -1
- package/dist/module/tests/TimerPicker.test.js.map +1 -1
- package/dist/module/utils/colorToRgba.js +35 -4
- package/dist/module/utils/colorToRgba.js.map +1 -1
- package/dist/module/utils/generateNumbers.js +68 -0
- package/dist/module/utils/generateNumbers.js.map +1 -1
- package/dist/module/utils/getAdjustedLimit.js +25 -0
- package/dist/module/utils/getAdjustedLimit.js.map +1 -1
- package/dist/module/utils/getDurationAndIndexFromScrollOffset.js +38 -0
- package/dist/module/utils/getDurationAndIndexFromScrollOffset.js.map +1 -1
- package/dist/module/utils/getInitialScrollIndex.js +38 -0
- package/dist/module/utils/getInitialScrollIndex.js.map +1 -1
- package/dist/module/utils/getSafeInitialValue.js +28 -0
- package/dist/module/utils/getSafeInitialValue.js.map +1 -1
- package/dist/module/utils/padNumber.js +25 -0
- package/dist/module/utils/padNumber.js.map +1 -1
- package/dist/typescript/components/DurationScroll/DurationScroll.d.ts +4 -0
- package/dist/typescript/components/DurationScroll/index.d.ts +2 -4
- package/dist/typescript/components/DurationScroll/types.d.ts +13 -9
- package/dist/typescript/components/Modal/Modal.d.ts +5 -0
- package/dist/typescript/components/Modal/index.d.ts +2 -5
- package/dist/typescript/components/TimerPicker/TimerPicker.d.ts +4 -0
- package/dist/typescript/components/TimerPicker/index.d.ts +3 -4
- package/dist/typescript/components/TimerPicker/styles.d.ts +1169 -771
- package/dist/typescript/components/TimerPicker/types.d.ts +26 -10
- package/dist/typescript/components/TimerPickerModal/TimerPickerModal.d.ts +4 -0
- package/dist/typescript/components/TimerPickerModal/index.d.ts +3 -4
- package/dist/typescript/components/TimerPickerModal/styles.d.ts +722 -474
- package/dist/typescript/components/TimerPickerModal/types.d.ts +8 -5
- package/dist/typescript/index.d.ts +2 -6
- package/dist/typescript/utils/colorToRgba.d.ts +34 -0
- package/dist/typescript/utils/generateNumbers.d.ts +66 -0
- package/dist/typescript/utils/getAdjustedLimit.d.ts +27 -2
- package/dist/typescript/utils/getDurationAndIndexFromScrollOffset.d.ts +38 -0
- package/dist/typescript/utils/getInitialScrollIndex.d.ts +38 -0
- package/dist/typescript/utils/getSafeInitialValue.d.ts +29 -0
- package/dist/typescript/utils/padNumber.d.ts +25 -0
- package/package.json +10 -27
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
2
|
import type { View, TouchableOpacity, Text } from "react-native";
|
|
3
3
|
import type Modal from "../Modal";
|
|
4
4
|
import type { TimerPickerProps } from "../TimerPicker/types";
|
|
5
5
|
import type { CustomTimerPickerModalStyles } from "./styles";
|
|
6
6
|
export interface TimerPickerModalRef {
|
|
7
7
|
latestDuration: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
days: RefObject<number> | undefined;
|
|
9
|
+
hours: RefObject<number> | undefined;
|
|
10
|
+
minutes: RefObject<number> | undefined;
|
|
11
|
+
seconds: RefObject<number> | undefined;
|
|
11
12
|
};
|
|
12
13
|
reset: (options?: {
|
|
13
14
|
animated?: boolean;
|
|
14
15
|
}) => void;
|
|
15
16
|
setValue: (value: {
|
|
17
|
+
days: number;
|
|
16
18
|
hours: number;
|
|
17
19
|
minutes: number;
|
|
18
20
|
seconds: number;
|
|
@@ -33,7 +35,8 @@ export interface TimerPickerModalProps extends TimerPickerProps {
|
|
|
33
35
|
modalTitle?: string;
|
|
34
36
|
modalTitleProps?: React.ComponentProps<typeof Text>;
|
|
35
37
|
onCancel?: () => void;
|
|
36
|
-
onConfirm: ({ hours, minutes, seconds, }: {
|
|
38
|
+
onConfirm: ({ days, hours, minutes, seconds, }: {
|
|
39
|
+
days: number;
|
|
37
40
|
hours: number;
|
|
38
41
|
minutes: number;
|
|
39
42
|
seconds: number;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export { default as TimerPickerModal } from "./components/TimerPickerModal";
|
|
2
|
-
export {
|
|
3
|
-
export { CustomTimerPickerModalStyles } from "./components/TimerPickerModal/styles";
|
|
4
|
-
export { default as TimerPicker } from "./components/TimerPicker";
|
|
5
|
-
export { TimerPickerProps, TimerPickerRef, } from "./components/TimerPicker/types";
|
|
6
|
-
export { CustomTimerPickerStyles } from "./components/TimerPicker/styles";
|
|
1
|
+
export { default as TimerPickerModal, TimerPickerModalProps, TimerPickerModalRef, CustomTimerPickerModalStyles, } from "./components/TimerPickerModal";
|
|
2
|
+
export { default as TimerPicker, TimerPickerProps, TimerPickerRef, CustomTimerPickerStyles, } from "./components/TimerPicker";
|
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts various color formats to RGBA string representation.
|
|
3
|
+
* This function is specifically required for expo-linear-gradient on iOS to handle transparent colors correctly.
|
|
4
|
+
* It supports named colors, RGB, and hex color formats.
|
|
5
|
+
*
|
|
6
|
+
* @param {Object} variables - The input variables object
|
|
7
|
+
* @param {string} variables.color - The color to convert. Can be:
|
|
8
|
+
* - Named color (e.g., 'transparent', 'black', 'white', 'blue', 'green', 'gray', 'red')
|
|
9
|
+
* - RGB format (e.g., 'rgb(255, 0, 0)')
|
|
10
|
+
* - Hex format (e.g., '#FF0000' or '#F00')
|
|
11
|
+
* @param {number} [variables.opacity=1] - The opacity value between 0 and 1
|
|
12
|
+
*
|
|
13
|
+
* @returns {string} The color in RGBA format (e.g., 'rgba(255, 0, 0, 0.5)')
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Using named color
|
|
17
|
+
* colorToRgba({ color: 'transparent' })
|
|
18
|
+
* // Returns: 'rgba(0, 0, 0, 0)'
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Using RGB with custom opacity
|
|
22
|
+
* colorToRgba({ color: 'rgb(255, 0, 0)', opacity: 0.5 })
|
|
23
|
+
* // Returns: 'rgba(255, 0, 0, 0.5)'
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Using hex color
|
|
27
|
+
* colorToRgba({ color: '#FF0000' })
|
|
28
|
+
* // Returns: 'rgba(255, 0, 0, 1)'
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Using short hex color
|
|
32
|
+
* colorToRgba({ color: '#F00' })
|
|
33
|
+
* // Returns: 'rgba(255, 0, 0, 1)'
|
|
34
|
+
*/
|
|
1
35
|
export declare const colorToRgba: (variables: {
|
|
2
36
|
color: string;
|
|
3
37
|
opacity?: number;
|
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an array of formatted numbers for a number picker, with support for infinite scroll,
|
|
3
|
+
* padding, and number repetition.
|
|
4
|
+
*
|
|
5
|
+
* @param {number} numberOfItems - Total number of items to generate
|
|
6
|
+
* @param {Object} options - Configuration options for number generation
|
|
7
|
+
* @param {boolean} [options.disableInfiniteScroll] - Whether to disable infinite scroll
|
|
8
|
+
* @param {number} options.interval - The interval between consecutive numbers
|
|
9
|
+
* @param {boolean} [options.padNumbersWithZero] - Whether to pad single-digit numbers with leading zeros
|
|
10
|
+
* @param {number} options.padWithNItems - Number of empty items to pad with
|
|
11
|
+
* @param {number} options.repeatNTimes - How many times to repeat the number sequence
|
|
12
|
+
*
|
|
13
|
+
* @returns {string[]} Array of formatted number strings
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Generate numbers 0-9 with padding
|
|
17
|
+
* generateNumbers(10, {
|
|
18
|
+
* interval: 1,
|
|
19
|
+
* padWithNItems: 2,
|
|
20
|
+
* repeatNTimes: 1,
|
|
21
|
+
* padNumbersWithZero: true
|
|
22
|
+
* })
|
|
23
|
+
* // Returns: ['', '', '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '', '']
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Generate even numbers with infinite scroll
|
|
27
|
+
* generateNumbers(5, {
|
|
28
|
+
* interval: 2,
|
|
29
|
+
* padWithNItems: 2,
|
|
30
|
+
* repeatNTimes: 3,
|
|
31
|
+
* disableInfiniteScroll: false
|
|
32
|
+
* })
|
|
33
|
+
* // Returns: ['0', '2', '4', '6', '8', '0', '2', '4', '6', '8', '0', '2', '4', '6', '8']
|
|
34
|
+
*/
|
|
1
35
|
export declare const generateNumbers: (numberOfItems: number, options: {
|
|
2
36
|
disableInfiniteScroll?: boolean;
|
|
3
37
|
interval: number;
|
|
@@ -5,6 +39,38 @@ export declare const generateNumbers: (numberOfItems: number, options: {
|
|
|
5
39
|
padWithNItems: number;
|
|
6
40
|
repeatNTimes: number;
|
|
7
41
|
}) => string[];
|
|
42
|
+
/**
|
|
43
|
+
* Generates an array of formatted 12-hour time strings (AM/PM) for a time picker.
|
|
44
|
+
* Supports infinite scroll, padding, and number repetition.
|
|
45
|
+
*
|
|
46
|
+
* @param {Object} options - Configuration options for time generation
|
|
47
|
+
* @param {boolean} [options.disableInfiniteScroll] - Whether to disable infinite scroll
|
|
48
|
+
* @param {number} options.interval - The interval between hours (must be a divisor of 12)
|
|
49
|
+
* @param {boolean} [options.padNumbersWithZero] - Whether to pad single-digit hours with leading zeros
|
|
50
|
+
* @param {number} options.padWithNItems - Number of empty items to pad with
|
|
51
|
+
* @param {number} [options.repeatNTimes] - How many times to repeat the time sequence (defaults to 1)
|
|
52
|
+
*
|
|
53
|
+
* @returns {string[]} Array of formatted 12-hour time strings
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Generate hours with 1-hour interval
|
|
57
|
+
* generate12HourNumbers({
|
|
58
|
+
* interval: 1,
|
|
59
|
+
* padWithNItems: 2,
|
|
60
|
+
* padNumbersWithZero: true
|
|
61
|
+
* })
|
|
62
|
+
* // Returns: ['', '', '12 AM', '01 AM', '02 AM', ..., '11 PM', '', '']
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Generate hours with 2-hour interval and infinite scroll
|
|
66
|
+
* generate12HourNumbers({
|
|
67
|
+
* interval: 2,
|
|
68
|
+
* padWithNItems: 2,
|
|
69
|
+
* repeatNTimes: 2,
|
|
70
|
+
* disableInfiniteScroll: false
|
|
71
|
+
* })
|
|
72
|
+
* // Returns: ['12 AM', '2 AM', '4 AM', ..., '10 PM', '12 AM', '2 AM', ...]
|
|
73
|
+
*/
|
|
8
74
|
export declare const generate12HourNumbers: (options: {
|
|
9
75
|
disableInfiniteScroll?: boolean;
|
|
10
76
|
interval: number;
|
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Limit } from "../components/DurationScroll/types";
|
|
2
|
+
/**
|
|
3
|
+
* Adjusts and validates the min/max limits for a scrollable number picker.
|
|
4
|
+
* Ensures limits are within valid bounds and handles edge cases.
|
|
5
|
+
*
|
|
6
|
+
* @param {Limit | undefined} limit - The input limit object containing optional min and max values
|
|
7
|
+
* @param {number} numberOfItems - Total number of items in the picker
|
|
8
|
+
* @param {number} interval - The interval between consecutive numbers
|
|
9
|
+
*
|
|
10
|
+
* @returns {{ max: number; min: number }} An object containing the adjusted min and max limits
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // With valid limits
|
|
14
|
+
* getAdjustedLimit({ min: 5, max: 15 }, 20, 1)
|
|
15
|
+
* // Returns: { max: 15, min: 5 }
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // With out-of-bounds limits
|
|
19
|
+
* getAdjustedLimit({ min: -5, max: 25 }, 20, 1)
|
|
20
|
+
* // Returns: { max: 19, min: 0 }
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // With invalid limits (max < min)
|
|
24
|
+
* getAdjustedLimit({ min: 15, max: 5 }, 20, 1)
|
|
25
|
+
* // Returns: { max: 19, min: 0 }
|
|
26
|
+
*/
|
|
27
|
+
export declare const getAdjustedLimit: (limit: Limit | undefined, numberOfItems: number, interval: number) => {
|
|
3
28
|
max: number;
|
|
4
29
|
min: number;
|
|
5
30
|
};
|
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the duration value and index from a scroll offset in a number picker.
|
|
3
|
+
* Handles both infinite and non-infinite scroll modes, taking into account padding and item height.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} variables - Configuration object for scroll offset calculation
|
|
6
|
+
* @param {boolean} variables.disableInfiniteScroll - Whether infinite scroll is disabled
|
|
7
|
+
* @param {number} variables.interval - The interval between consecutive numbers
|
|
8
|
+
* @param {number} variables.itemHeight - Height of each item in the picker
|
|
9
|
+
* @param {number} variables.numberOfItems - Total number of items in the picker
|
|
10
|
+
* @param {number} variables.padWithNItems - Number of empty items to pad with
|
|
11
|
+
* @param {number} variables.yContentOffset - The vertical scroll offset
|
|
12
|
+
*
|
|
13
|
+
* @returns {{ duration: number; index: number }} Object containing the calculated duration and index
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // With infinite scroll enabled
|
|
17
|
+
* getDurationAndIndexFromScrollOffset({
|
|
18
|
+
* disableInfiniteScroll: false,
|
|
19
|
+
* interval: 1,
|
|
20
|
+
* itemHeight: 50,
|
|
21
|
+
* numberOfItems: 24,
|
|
22
|
+
* padWithNItems: 2,
|
|
23
|
+
* yContentOffset: 100
|
|
24
|
+
* })
|
|
25
|
+
* // Returns: { duration: 2, index: 2 }
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // With infinite scroll disabled
|
|
29
|
+
* getDurationAndIndexFromScrollOffset({
|
|
30
|
+
* disableInfiniteScroll: true,
|
|
31
|
+
* interval: 1,
|
|
32
|
+
* itemHeight: 50,
|
|
33
|
+
* numberOfItems: 24,
|
|
34
|
+
* padWithNItems: 2,
|
|
35
|
+
* yContentOffset: 100
|
|
36
|
+
* })
|
|
37
|
+
* // Returns: { duration: 2, index: 2 }
|
|
38
|
+
*/
|
|
1
39
|
export declare const getDurationAndIndexFromScrollOffset: (variables: {
|
|
2
40
|
disableInfiniteScroll: boolean;
|
|
3
41
|
interval: number;
|
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the initial scroll index for a number picker based on the desired value and configuration.
|
|
3
|
+
* Handles both infinite and non-infinite scroll modes, taking into account padding and repetition.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} variables - Configuration object for scroll index calculation
|
|
6
|
+
* @param {boolean} variables.disableInfiniteScroll - Whether infinite scroll is disabled
|
|
7
|
+
* @param {number} variables.interval - The interval between consecutive numbers
|
|
8
|
+
* @param {number} variables.numberOfItems - Total number of items in the picker
|
|
9
|
+
* @param {number} variables.padWithNItems - Number of empty items to pad with
|
|
10
|
+
* @param {number} variables.repeatNumbersNTimes - How many times to repeat the number sequence
|
|
11
|
+
* @param {number} variables.value - The desired initial value
|
|
12
|
+
*
|
|
13
|
+
* @returns {number} The calculated initial scroll index
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // With infinite scroll enabled
|
|
17
|
+
* getInitialScrollIndex({
|
|
18
|
+
* disableInfiniteScroll: false,
|
|
19
|
+
* interval: 1,
|
|
20
|
+
* numberOfItems: 24,
|
|
21
|
+
* padWithNItems: 2,
|
|
22
|
+
* repeatNumbersNTimes: 3,
|
|
23
|
+
* value: 12
|
|
24
|
+
* })
|
|
25
|
+
* // Returns: 38
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // With infinite scroll disabled
|
|
29
|
+
* getInitialScrollIndex({
|
|
30
|
+
* disableInfiniteScroll: true,
|
|
31
|
+
* interval: 1,
|
|
32
|
+
* numberOfItems: 24,
|
|
33
|
+
* padWithNItems: 2,
|
|
34
|
+
* repeatNumbersNTimes: 1,
|
|
35
|
+
* value: 12
|
|
36
|
+
* })
|
|
37
|
+
* // Returns: 12
|
|
38
|
+
*/
|
|
1
39
|
export declare const getInitialScrollIndex: (variables: {
|
|
2
40
|
disableInfiniteScroll: boolean;
|
|
3
41
|
interval: number;
|
|
@@ -1,8 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safely extracts and validates initial duration values, ensuring all values are valid numbers.
|
|
3
|
+
* Returns a duration object with safe default values (0) for any invalid or missing inputs.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} [initialValue] - Optional initial duration values
|
|
6
|
+
* @param {number} [initialValue.days] - Initial days value
|
|
7
|
+
* @param {number} [initialValue.hours] - Initial hours value
|
|
8
|
+
* @param {number} [initialValue.minutes] - Initial minutes value
|
|
9
|
+
* @param {number} [initialValue.seconds] - Initial seconds value
|
|
10
|
+
*
|
|
11
|
+
* @returns {{ days: number; hours: number; minutes: number; seconds: number }} An object containing safe duration values
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // With valid values
|
|
15
|
+
* getSafeInitialValue({ days: 1, hours: 2, minutes: 30, seconds: 45 })
|
|
16
|
+
* // Returns: { days: 1, hours: 2, minutes: 30, seconds: 45 }
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // With invalid values
|
|
20
|
+
* getSafeInitialValue({ days: NaN, hours: 'invalid', minutes: undefined })
|
|
21
|
+
* // Returns: { days: 0, hours: 0, minutes: 0, seconds: 0 }
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // With undefined input
|
|
25
|
+
* getSafeInitialValue(undefined)
|
|
26
|
+
* // Returns: { days: 0, hours: 0, minutes: 0, seconds: 0 }
|
|
27
|
+
*/
|
|
1
28
|
export declare const getSafeInitialValue: (initialValue: {
|
|
29
|
+
days?: number;
|
|
2
30
|
hours?: number;
|
|
3
31
|
minutes?: number;
|
|
4
32
|
seconds?: number;
|
|
5
33
|
} | undefined) => {
|
|
34
|
+
days: number;
|
|
6
35
|
hours: number;
|
|
7
36
|
minutes: number;
|
|
8
37
|
seconds: number;
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats a number by optionally padding it with a leading zero or space.
|
|
3
|
+
* Numbers less than 10 are padded based on the options provided.
|
|
4
|
+
*
|
|
5
|
+
* @param {number} value - The number to format
|
|
6
|
+
* @param {Object} [options] - Optional formatting options
|
|
7
|
+
* @param {boolean} [options.padWithZero] - Whether to pad with zero (true) or space (false)
|
|
8
|
+
*
|
|
9
|
+
* @returns {string} The formatted number string
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Pad with zero
|
|
13
|
+
* padNumber(5, { padWithZero: true })
|
|
14
|
+
* // Returns: '05'
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Pad with space
|
|
18
|
+
* padNumber(5, { padWithZero: false })
|
|
19
|
+
* // Returns: ' 5'
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // No padding needed
|
|
23
|
+
* padNumber(15)
|
|
24
|
+
* // Returns: '15'
|
|
25
|
+
*/
|
|
1
26
|
export declare const padNumber: (value: number, options?: {
|
|
2
27
|
padWithZero?: boolean;
|
|
3
28
|
}) => string;
|
package/package.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/troberts-28"
|
|
7
7
|
},
|
|
8
8
|
"license": "MIT",
|
|
9
|
-
"version": "2.
|
|
9
|
+
"version": "2.2.0",
|
|
10
10
|
"main": "dist/commonjs/index.js",
|
|
11
11
|
"module": "dist/module/index.js",
|
|
12
12
|
"types": "dist/typescript/index.d.ts",
|
|
13
13
|
"typings": "dist/typescript/index.d.ts",
|
|
14
|
-
"packageManager": "yarn@
|
|
14
|
+
"packageManager": "yarn@4.9.1",
|
|
15
15
|
"workspaces": {
|
|
16
16
|
"packages": [
|
|
17
17
|
"examples/*"
|
|
@@ -21,12 +21,13 @@
|
|
|
21
21
|
"setup": "yarn install",
|
|
22
22
|
"start": " yarn workspace example-expo start",
|
|
23
23
|
"start-bare:android": "yarn workspace example-bare android && yarn workspace example-bare start",
|
|
24
|
-
"start-bare:ios": "yarn workspace example-bare
|
|
24
|
+
"start-bare:ios": "yarn workspace example-bare ios && yarn workspace example-bare start",
|
|
25
25
|
"test": "jest --forceExit --silent",
|
|
26
26
|
"build": "bob build",
|
|
27
27
|
"clean": "rm yarn.lock && rm -rf ./node_modules && yarn install",
|
|
28
28
|
"lint": "eslint --ext .ts,.tsx .",
|
|
29
29
|
"lint:fix": "eslint --ext .ts,.tsx . --fix",
|
|
30
|
+
"ts": "tsc --noEmit",
|
|
30
31
|
"prepare": "yarn build"
|
|
31
32
|
},
|
|
32
33
|
"homepage": "https://github.com/troberts-28/react-native-timer-picker",
|
|
@@ -87,36 +88,17 @@
|
|
|
87
88
|
"engines": {
|
|
88
89
|
"node": ">=16.0.0"
|
|
89
90
|
},
|
|
90
|
-
"jest": {
|
|
91
|
-
"preset": "react-native",
|
|
92
|
-
"moduleFileExtensions": [
|
|
93
|
-
"ts",
|
|
94
|
-
"tsx",
|
|
95
|
-
"js",
|
|
96
|
-
"jsx",
|
|
97
|
-
"json",
|
|
98
|
-
"node"
|
|
99
|
-
],
|
|
100
|
-
"testEnvironment": "node",
|
|
101
|
-
"modulePathIgnorePatterns": [
|
|
102
|
-
"<rootDir>/dist/",
|
|
103
|
-
"<rootDir>/examples/"
|
|
104
|
-
],
|
|
105
|
-
"transformIgnorePatterns": []
|
|
106
|
-
},
|
|
107
91
|
"peerDependencies": {
|
|
108
92
|
"react": ">=18.2.0",
|
|
109
93
|
"react-native": ">=0.72.0"
|
|
110
94
|
},
|
|
111
95
|
"devDependencies": {
|
|
112
96
|
"@babel/core": "^7.20.0",
|
|
113
|
-
"@babel/plugin-transform-class-properties": "^7.22.5",
|
|
114
|
-
"@babel/plugin-transform-flow-strip-types": "^7.22.5",
|
|
115
|
-
"@babel/plugin-transform-private-methods": "^7.22.5",
|
|
116
97
|
"@testing-library/react-native": "^12.0.0",
|
|
117
98
|
"@types/jest": "^29.0.0",
|
|
118
|
-
"@types/react": "
|
|
119
|
-
"@types/react-native": "
|
|
99
|
+
"@types/react": ">=18.2.0",
|
|
100
|
+
"@types/react-native": "0.72.0",
|
|
101
|
+
"@types/react-test-renderer": ">=18.2.0",
|
|
120
102
|
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
|
121
103
|
"@typescript-eslint/parser": "^5.49.0",
|
|
122
104
|
"babel-jest": "^29.6.2",
|
|
@@ -125,11 +107,12 @@
|
|
|
125
107
|
"eslint-plugin-react": "^7.33.1",
|
|
126
108
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
127
109
|
"eslint-plugin-sort-destructure-keys": "^1.5.0",
|
|
128
|
-
"eslint-plugin-typescript-sort-keys": "^3.
|
|
110
|
+
"eslint-plugin-typescript-sort-keys": "^2.3.0",
|
|
129
111
|
"jest": "^29.0.0",
|
|
130
112
|
"metro-react-native-babel-preset": "^0.71.1",
|
|
113
|
+
"prettier": "2.8.8",
|
|
131
114
|
"react-native-builder-bob": "^0.18.3",
|
|
132
|
-
"react-test-renderer": "
|
|
115
|
+
"react-test-renderer": "18.2.0",
|
|
133
116
|
"typescript": "^4.7.4"
|
|
134
117
|
},
|
|
135
118
|
"react-native-builder-bob": {
|