react-native-timer-picker 2.1.1 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +250 -174
  2. package/dist/commonjs/components/DurationScroll/DurationScroll.js +417 -0
  3. package/dist/commonjs/components/DurationScroll/DurationScroll.js.map +1 -0
  4. package/dist/commonjs/components/DurationScroll/index.js +20 -392
  5. package/dist/commonjs/components/DurationScroll/index.js.map +1 -1
  6. package/dist/commonjs/components/DurationScroll/types.js.map +1 -1
  7. package/dist/commonjs/components/Modal/Modal.js +107 -0
  8. package/dist/commonjs/components/Modal/Modal.js.map +1 -0
  9. package/dist/commonjs/components/Modal/index.js +20 -101
  10. package/dist/commonjs/components/Modal/index.js.map +1 -1
  11. package/dist/commonjs/components/TimerPicker/TimerPicker.js +225 -0
  12. package/dist/commonjs/components/TimerPicker/TimerPicker.js.map +1 -0
  13. package/dist/commonjs/components/TimerPicker/index.js +29 -166
  14. package/dist/commonjs/components/TimerPicker/index.js.map +1 -1
  15. package/dist/commonjs/components/TimerPicker/styles.js.map +1 -1
  16. package/dist/commonjs/components/TimerPicker/types.js.map +1 -1
  17. package/dist/commonjs/components/TimerPickerModal/TimerPickerModal.js +143 -0
  18. package/dist/commonjs/components/TimerPickerModal/TimerPickerModal.js.map +1 -0
  19. package/dist/commonjs/components/TimerPickerModal/index.js +30 -131
  20. package/dist/commonjs/components/TimerPickerModal/index.js.map +1 -1
  21. package/dist/commonjs/components/TimerPickerModal/types.js.map +1 -1
  22. package/dist/commonjs/index.js +9 -13
  23. package/dist/commonjs/index.js.map +1 -1
  24. package/dist/commonjs/tests/DurationScroll.test.js +94 -0
  25. package/dist/commonjs/tests/DurationScroll.test.js.map +1 -1
  26. package/dist/commonjs/tests/Modal.test.js +79 -2
  27. package/dist/commonjs/tests/Modal.test.js.map +1 -1
  28. package/dist/commonjs/tests/TimerPicker.test.js +119 -1
  29. package/dist/commonjs/tests/TimerPicker.test.js.map +1 -1
  30. package/dist/commonjs/tests/TimerPickerModal.test.js +120 -0
  31. package/dist/commonjs/tests/TimerPickerModal.test.js.map +1 -1
  32. package/dist/commonjs/tests/colorToRgba.test.js +176 -0
  33. package/dist/commonjs/tests/colorToRgba.test.js.map +1 -0
  34. package/dist/commonjs/tests/generateNumbers.test.js +350 -0
  35. package/dist/commonjs/tests/generateNumbers.test.js.map +1 -0
  36. package/dist/commonjs/tests/getAdjustedLimit.test.js +324 -0
  37. package/dist/commonjs/tests/getAdjustedLimit.test.js.map +1 -0
  38. package/dist/commonjs/tests/getDurationAndIndexFromScrollOffset.test.js +424 -0
  39. package/dist/commonjs/tests/getDurationAndIndexFromScrollOffset.test.js.map +1 -0
  40. package/dist/commonjs/tests/getInitialScrollIndex.test.js +396 -0
  41. package/dist/commonjs/tests/getInitialScrollIndex.test.js.map +1 -0
  42. package/dist/commonjs/tests/getSafeInitialValue.test.js +497 -0
  43. package/dist/commonjs/tests/getSafeInitialValue.test.js.map +1 -0
  44. package/dist/commonjs/tests/padNumber.test.js +301 -0
  45. package/dist/commonjs/tests/padNumber.test.js.map +1 -0
  46. package/dist/commonjs/utils/colorToRgba.js +40 -4
  47. package/dist/commonjs/utils/colorToRgba.js.map +1 -1
  48. package/dist/commonjs/utils/generateNumbers.js +67 -0
  49. package/dist/commonjs/utils/generateNumbers.js.map +1 -1
  50. package/dist/commonjs/utils/getAdjustedLimit.js +28 -3
  51. package/dist/commonjs/utils/getAdjustedLimit.js.map +1 -1
  52. package/dist/commonjs/utils/getDurationAndIndexFromScrollOffset.js +38 -0
  53. package/dist/commonjs/utils/getDurationAndIndexFromScrollOffset.js.map +1 -1
  54. package/dist/commonjs/utils/getInitialScrollIndex.js +38 -0
  55. package/dist/commonjs/utils/getInitialScrollIndex.js.map +1 -1
  56. package/dist/commonjs/utils/getSafeInitialValue.js +28 -0
  57. package/dist/commonjs/utils/getSafeInitialValue.js.map +1 -1
  58. package/dist/commonjs/utils/padNumber.js +25 -0
  59. package/dist/commonjs/utils/padNumber.js.map +1 -1
  60. package/dist/module/components/DurationScroll/DurationScroll.js +410 -0
  61. package/dist/module/components/DurationScroll/DurationScroll.js.map +1 -0
  62. package/dist/module/components/DurationScroll/index.js +2 -390
  63. package/dist/module/components/DurationScroll/index.js.map +1 -1
  64. package/dist/module/components/DurationScroll/types.js.map +1 -1
  65. package/dist/module/components/Modal/Modal.js +99 -0
  66. package/dist/module/components/Modal/Modal.js.map +1 -0
  67. package/dist/module/components/Modal/index.js +2 -98
  68. package/dist/module/components/Modal/index.js.map +1 -1
  69. package/dist/module/components/TimerPicker/TimerPicker.js +217 -0
  70. package/dist/module/components/TimerPicker/TimerPicker.js.map +1 -0
  71. package/dist/module/components/TimerPicker/index.js +3 -166
  72. package/dist/module/components/TimerPicker/index.js.map +1 -1
  73. package/dist/module/components/TimerPicker/styles.js.map +1 -1
  74. package/dist/module/components/TimerPicker/types.js.map +1 -1
  75. package/dist/module/components/TimerPickerModal/TimerPickerModal.js +135 -0
  76. package/dist/module/components/TimerPickerModal/TimerPickerModal.js.map +1 -0
  77. package/dist/module/components/TimerPickerModal/index.js +3 -130
  78. package/dist/module/components/TimerPickerModal/index.js.map +1 -1
  79. package/dist/module/components/TimerPickerModal/types.js.map +1 -1
  80. package/dist/module/index.js +2 -6
  81. package/dist/module/index.js.map +1 -1
  82. package/dist/module/tests/DurationScroll.test.js +94 -0
  83. package/dist/module/tests/DurationScroll.test.js.map +1 -1
  84. package/dist/module/tests/Modal.test.js +80 -3
  85. package/dist/module/tests/Modal.test.js.map +1 -1
  86. package/dist/module/tests/TimerPicker.test.js +119 -1
  87. package/dist/module/tests/TimerPicker.test.js.map +1 -1
  88. package/dist/module/tests/TimerPickerModal.test.js +121 -1
  89. package/dist/module/tests/TimerPickerModal.test.js.map +1 -1
  90. package/dist/module/tests/colorToRgba.test.js +174 -0
  91. package/dist/module/tests/colorToRgba.test.js.map +1 -0
  92. package/dist/module/tests/generateNumbers.test.js +348 -0
  93. package/dist/module/tests/generateNumbers.test.js.map +1 -0
  94. package/dist/module/tests/getAdjustedLimit.test.js +322 -0
  95. package/dist/module/tests/getAdjustedLimit.test.js.map +1 -0
  96. package/dist/module/tests/getDurationAndIndexFromScrollOffset.test.js +422 -0
  97. package/dist/module/tests/getDurationAndIndexFromScrollOffset.test.js.map +1 -0
  98. package/dist/module/tests/getInitialScrollIndex.test.js +394 -0
  99. package/dist/module/tests/getInitialScrollIndex.test.js.map +1 -0
  100. package/dist/module/tests/getSafeInitialValue.test.js +495 -0
  101. package/dist/module/tests/getSafeInitialValue.test.js.map +1 -0
  102. package/dist/module/tests/padNumber.test.js +299 -0
  103. package/dist/module/tests/padNumber.test.js.map +1 -0
  104. package/dist/module/utils/colorToRgba.js +40 -4
  105. package/dist/module/utils/colorToRgba.js.map +1 -1
  106. package/dist/module/utils/generateNumbers.js +68 -0
  107. package/dist/module/utils/generateNumbers.js.map +1 -1
  108. package/dist/module/utils/getAdjustedLimit.js +28 -3
  109. package/dist/module/utils/getAdjustedLimit.js.map +1 -1
  110. package/dist/module/utils/getDurationAndIndexFromScrollOffset.js +38 -0
  111. package/dist/module/utils/getDurationAndIndexFromScrollOffset.js.map +1 -1
  112. package/dist/module/utils/getInitialScrollIndex.js +38 -0
  113. package/dist/module/utils/getInitialScrollIndex.js.map +1 -1
  114. package/dist/module/utils/getSafeInitialValue.js +28 -0
  115. package/dist/module/utils/getSafeInitialValue.js.map +1 -1
  116. package/dist/module/utils/padNumber.js +25 -0
  117. package/dist/module/utils/padNumber.js.map +1 -1
  118. package/dist/typescript/components/DurationScroll/DurationScroll.d.ts +4 -0
  119. package/dist/typescript/components/DurationScroll/index.d.ts +2 -4
  120. package/dist/typescript/components/DurationScroll/types.d.ts +13 -9
  121. package/dist/typescript/components/Modal/Modal.d.ts +5 -0
  122. package/dist/typescript/components/Modal/index.d.ts +2 -5
  123. package/dist/typescript/components/TimerPicker/TimerPicker.d.ts +4 -0
  124. package/dist/typescript/components/TimerPicker/index.d.ts +3 -4
  125. package/dist/typescript/components/TimerPicker/styles.d.ts +922 -771
  126. package/dist/typescript/components/TimerPicker/types.d.ts +26 -10
  127. package/dist/typescript/components/TimerPickerModal/TimerPickerModal.d.ts +4 -0
  128. package/dist/typescript/components/TimerPickerModal/index.d.ts +3 -4
  129. package/dist/typescript/components/TimerPickerModal/styles.d.ts +570 -474
  130. package/dist/typescript/components/TimerPickerModal/types.d.ts +8 -5
  131. package/dist/typescript/index.d.ts +2 -6
  132. package/dist/typescript/utils/colorToRgba.d.ts +34 -0
  133. package/dist/typescript/utils/generateNumbers.d.ts +66 -0
  134. package/dist/typescript/utils/getAdjustedLimit.d.ts +27 -2
  135. package/dist/typescript/utils/getDurationAndIndexFromScrollOffset.d.ts +38 -0
  136. package/dist/typescript/utils/getInitialScrollIndex.d.ts +38 -0
  137. package/dist/typescript/utils/getSafeInitialValue.d.ts +29 -0
  138. package/dist/typescript/utils/padNumber.d.ts +25 -0
  139. package/package.json +12 -30
@@ -1,18 +1,20 @@
1
- import type { MutableRefObject } from "react";
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
- hours: MutableRefObject<number> | undefined;
9
- minutes: MutableRefObject<number> | undefined;
10
- seconds: MutableRefObject<number> | undefined;
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 { TimerPickerModalProps, TimerPickerModalRef, } from "./components/TimerPickerModal/types";
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 { LimitType } from "../components/DurationScroll/types";
2
- export declare const getAdjustedLimit: (limit: LimitType | undefined, numberOfItems: number, interval: number) => {
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.1.1",
9
+ "version": "2.2.1",
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@3.6.4",
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 android && yarn workspace example-bare start",
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",
@@ -43,9 +44,6 @@
43
44
  },
44
45
  "files": [
45
46
  "dist",
46
- "!**/__tests__",
47
- "!**/__fixtures__",
48
- "!**/__mocks__",
49
47
  "package.json",
50
48
  "README.md",
51
49
  "LICENSE"
@@ -87,36 +85,17 @@
87
85
  "engines": {
88
86
  "node": ">=16.0.0"
89
87
  },
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
88
  "peerDependencies": {
108
89
  "react": ">=18.2.0",
109
90
  "react-native": ">=0.72.0"
110
91
  },
111
92
  "devDependencies": {
112
93
  "@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
94
  "@testing-library/react-native": "^12.0.0",
117
95
  "@types/jest": "^29.0.0",
118
- "@types/react": "^18.0.27",
119
- "@types/react-native": "^0.70.6",
96
+ "@types/react": ">=18.2.0",
97
+ "@types/react-native": "0.72.0",
98
+ "@types/react-test-renderer": ">=18.2.0",
120
99
  "@typescript-eslint/eslint-plugin": "^5.49.0",
121
100
  "@typescript-eslint/parser": "^5.49.0",
122
101
  "babel-jest": "^29.6.2",
@@ -125,11 +104,14 @@
125
104
  "eslint-plugin-react": "^7.33.1",
126
105
  "eslint-plugin-react-hooks": "^4.6.0",
127
106
  "eslint-plugin-sort-destructure-keys": "^1.5.0",
128
- "eslint-plugin-typescript-sort-keys": "^3.1.0",
107
+ "eslint-plugin-typescript-sort-keys": "^2.3.0",
129
108
  "jest": "^29.0.0",
130
109
  "metro-react-native-babel-preset": "^0.71.1",
110
+ "prettier": "2.8.8",
111
+ "react": "18.2.0",
112
+ "react-native": "0.72.0",
131
113
  "react-native-builder-bob": "^0.18.3",
132
- "react-test-renderer": "^18.0.0",
114
+ "react-test-renderer": "18.2.0",
133
115
  "typescript": "^4.7.4"
134
116
  },
135
117
  "react-native-builder-bob": {