react-simplikit 0.0.53 → 0.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.
Files changed (153) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/README.md +2 -42
  3. package/dist/hooks/useAsyncEffect/useAsyncEffect.cjs +1 -0
  4. package/dist/hooks/useAsyncEffect/useAsyncEffect.mjs +1 -0
  5. package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.cjs +1 -0
  6. package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.mjs +1 -0
  7. package/dist/hooks/useConditionalEffect/useConditionalEffect.cjs +1 -0
  8. package/dist/hooks/useConditionalEffect/useConditionalEffect.mjs +1 -0
  9. package/dist/hooks/useDebouncedCallback/useDebouncedCallback.cjs +24 -6
  10. package/dist/hooks/useDebouncedCallback/useDebouncedCallback.d.cts +17 -7
  11. package/dist/hooks/useDebouncedCallback/useDebouncedCallback.d.mts +17 -7
  12. package/dist/hooks/useDebouncedCallback/useDebouncedCallback.mjs +24 -6
  13. package/dist/hooks/useDoubleClick/useDoubleClick.cjs +0 -4
  14. package/dist/hooks/useDoubleClick/useDoubleClick.d.cts +0 -4
  15. package/dist/hooks/useDoubleClick/useDoubleClick.d.mts +0 -4
  16. package/dist/hooks/useDoubleClick/useDoubleClick.mjs +0 -4
  17. package/dist/hooks/useGeolocation/useGeolocation.cjs +0 -4
  18. package/dist/hooks/useGeolocation/useGeolocation.d.cts +0 -4
  19. package/dist/hooks/useGeolocation/useGeolocation.d.mts +0 -4
  20. package/dist/hooks/useGeolocation/useGeolocation.mjs +0 -4
  21. package/dist/hooks/useImpressionRef/useImpressionRef.cjs +7 -5
  22. package/dist/hooks/useImpressionRef/useImpressionRef.d.cts +0 -4
  23. package/dist/hooks/useImpressionRef/useImpressionRef.d.mts +0 -4
  24. package/dist/hooks/useImpressionRef/useImpressionRef.mjs +7 -5
  25. package/dist/hooks/useInputState/useInputState.cjs +9 -3
  26. package/dist/hooks/useInputState/useInputState.d.cts +11 -4
  27. package/dist/hooks/useInputState/useInputState.d.mts +11 -4
  28. package/dist/hooks/useInputState/useInputState.mjs +9 -3
  29. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -5
  30. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.d.cts +1 -5
  31. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.d.mts +1 -5
  32. package/dist/hooks/useIntersectionObserver/useIntersectionObserver.mjs +1 -5
  33. package/dist/hooks/useList/useList.cjs +11 -8
  34. package/dist/hooks/useList/useList.d.cts +12 -9
  35. package/dist/hooks/useList/useList.d.mts +12 -9
  36. package/dist/hooks/useList/useList.mjs +11 -8
  37. package/dist/hooks/useLoading/useLoading.cjs +3 -5
  38. package/dist/hooks/useLoading/useLoading.d.cts +2 -5
  39. package/dist/hooks/useLoading/useLoading.d.mts +2 -5
  40. package/dist/hooks/useLoading/useLoading.mjs +3 -5
  41. package/dist/hooks/useLongPress/useLongPress.cjs +0 -4
  42. package/dist/hooks/useLongPress/useLongPress.d.cts +0 -4
  43. package/dist/hooks/useLongPress/useLongPress.d.mts +0 -4
  44. package/dist/hooks/useLongPress/useLongPress.mjs +0 -4
  45. package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.cjs +0 -4
  46. package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.d.cts +0 -4
  47. package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.d.mts +0 -4
  48. package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.mjs +0 -4
  49. package/dist/hooks/usePreservedReference/usePreservedReference.cjs +1 -0
  50. package/dist/hooks/usePreservedReference/usePreservedReference.mjs +1 -0
  51. package/dist/hooks/useRefEffect/useRefEffect.cjs +1 -0
  52. package/dist/hooks/useRefEffect/useRefEffect.mjs +1 -0
  53. package/dist/hooks/useSet/useSet.cjs +11 -2
  54. package/dist/hooks/useSet/useSet.d.cts +11 -2
  55. package/dist/hooks/useSet/useSet.d.mts +11 -2
  56. package/dist/hooks/useSet/useSet.mjs +11 -2
  57. package/dist/hooks/useStorageState/useStorageState.cjs +1 -0
  58. package/dist/hooks/useStorageState/useStorageState.d.cts +0 -4
  59. package/dist/hooks/useStorageState/useStorageState.d.mts +0 -4
  60. package/dist/hooks/useStorageState/useStorageState.mjs +1 -0
  61. package/dist/hooks/useThrottledCallback/useThrottledCallback.cjs +16 -9
  62. package/dist/hooks/useThrottledCallback/useThrottledCallback.d.cts +18 -11
  63. package/dist/hooks/useThrottledCallback/useThrottledCallback.d.mts +18 -11
  64. package/dist/hooks/useThrottledCallback/useThrottledCallback.mjs +16 -9
  65. package/dist/hooks/useVisibilityEvent/useVisibilityEvent.cjs +2 -4
  66. package/dist/hooks/useVisibilityEvent/useVisibilityEvent.d.cts +2 -4
  67. package/dist/hooks/useVisibilityEvent/useVisibilityEvent.d.mts +2 -4
  68. package/dist/hooks/useVisibilityEvent/useVisibilityEvent.mjs +2 -4
  69. package/dist/index.cjs +34 -0
  70. package/dist/index.d.cts +19 -1
  71. package/dist/index.d.mts +19 -1
  72. package/dist/index.mjs +18 -1
  73. package/dist/mobile/hooks/useAvoidKeyboard/index.d.cts +3 -0
  74. package/dist/mobile/hooks/useAvoidKeyboard/index.d.mts +3 -0
  75. package/dist/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.cjs +75 -0
  76. package/dist/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.d.cts +89 -0
  77. package/dist/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.d.mts +89 -0
  78. package/dist/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.mjs +75 -0
  79. package/dist/mobile/hooks/useBodyScrollLock/useBodyScrollLock.cjs +47 -0
  80. package/dist/mobile/hooks/useBodyScrollLock/useBodyScrollLock.d.cts +37 -0
  81. package/dist/mobile/hooks/useBodyScrollLock/useBodyScrollLock.d.mts +37 -0
  82. package/dist/mobile/hooks/useBodyScrollLock/useBodyScrollLock.mjs +47 -0
  83. package/dist/mobile/hooks/useKeyboardHeight/useKeyboardHeight.cjs +41 -0
  84. package/dist/mobile/hooks/useKeyboardHeight/useKeyboardHeight.d.cts +41 -0
  85. package/dist/mobile/hooks/useKeyboardHeight/useKeyboardHeight.d.mts +41 -0
  86. package/dist/mobile/hooks/useKeyboardHeight/useKeyboardHeight.mjs +41 -0
  87. package/dist/mobile/hooks/useNetworkStatus/useNetworkStatus.cjs +88 -0
  88. package/dist/mobile/hooks/useNetworkStatus/useNetworkStatus.d.cts +77 -0
  89. package/dist/mobile/hooks/useNetworkStatus/useNetworkStatus.d.mts +77 -0
  90. package/dist/mobile/hooks/useNetworkStatus/useNetworkStatus.mjs +88 -0
  91. package/dist/mobile/hooks/usePageVisibility/usePageVisibility.cjs +75 -0
  92. package/dist/mobile/hooks/usePageVisibility/usePageVisibility.d.cts +64 -0
  93. package/dist/mobile/hooks/usePageVisibility/usePageVisibility.d.mts +64 -0
  94. package/dist/mobile/hooks/usePageVisibility/usePageVisibility.mjs +75 -0
  95. package/dist/mobile/hooks/useSafeAreaInset/useSafeAreaInset.cjs +74 -0
  96. package/dist/mobile/hooks/useSafeAreaInset/useSafeAreaInset.d.cts +55 -0
  97. package/dist/mobile/hooks/useSafeAreaInset/useSafeAreaInset.d.mts +55 -0
  98. package/dist/mobile/hooks/useSafeAreaInset/useSafeAreaInset.mjs +74 -0
  99. package/dist/mobile/hooks/useScrollDirection/useScrollDirection.cjs +79 -0
  100. package/dist/mobile/hooks/useScrollDirection/useScrollDirection.d.cts +40 -0
  101. package/dist/mobile/hooks/useScrollDirection/useScrollDirection.d.mts +40 -0
  102. package/dist/mobile/hooks/useScrollDirection/useScrollDirection.mjs +79 -0
  103. package/dist/mobile/hooks/useVisualViewport/useVisualViewport.cjs +77 -0
  104. package/dist/mobile/hooks/useVisualViewport/useVisualViewport.d.cts +89 -0
  105. package/dist/mobile/hooks/useVisualViewport/useVisualViewport.d.mts +89 -0
  106. package/dist/mobile/hooks/useVisualViewport/useVisualViewport.mjs +77 -0
  107. package/dist/mobile/utils/disableBodyScrollLock/disableBodyScrollLock.cjs +55 -0
  108. package/dist/mobile/utils/disableBodyScrollLock/disableBodyScrollLock.d.cts +22 -0
  109. package/dist/mobile/utils/disableBodyScrollLock/disableBodyScrollLock.d.mts +22 -0
  110. package/dist/mobile/utils/disableBodyScrollLock/disableBodyScrollLock.mjs +55 -0
  111. package/dist/mobile/utils/enableBodyScrollLock/enableBodyScrollLock.cjs +49 -0
  112. package/dist/mobile/utils/enableBodyScrollLock/enableBodyScrollLock.d.cts +23 -0
  113. package/dist/mobile/utils/enableBodyScrollLock/enableBodyScrollLock.d.mts +23 -0
  114. package/dist/mobile/utils/enableBodyScrollLock/enableBodyScrollLock.mjs +49 -0
  115. package/dist/mobile/utils/getKeyboardHeight/getKeyboardHeight.cjs +35 -0
  116. package/dist/mobile/utils/getKeyboardHeight/getKeyboardHeight.d.cts +28 -0
  117. package/dist/mobile/utils/getKeyboardHeight/getKeyboardHeight.d.mts +28 -0
  118. package/dist/mobile/utils/getKeyboardHeight/getKeyboardHeight.mjs +35 -0
  119. package/dist/mobile/utils/getSafeAreaInset/getSafeAreaInset.cjs +58 -0
  120. package/dist/mobile/utils/getSafeAreaInset/getSafeAreaInset.d.cts +44 -0
  121. package/dist/mobile/utils/getSafeAreaInset/getSafeAreaInset.d.mts +44 -0
  122. package/dist/mobile/utils/getSafeAreaInset/getSafeAreaInset.mjs +58 -0
  123. package/dist/mobile/utils/isAndroid/isAndroid.cjs +32 -0
  124. package/dist/mobile/utils/isAndroid/isAndroid.d.cts +27 -0
  125. package/dist/mobile/utils/isAndroid/isAndroid.d.mts +27 -0
  126. package/dist/mobile/utils/isAndroid/isAndroid.mjs +32 -0
  127. package/dist/mobile/utils/isIOS/isIOS.cjs +37 -0
  128. package/dist/mobile/utils/isIOS/isIOS.d.cts +30 -0
  129. package/dist/mobile/utils/isIOS/isIOS.d.mts +30 -0
  130. package/dist/mobile/utils/isIOS/isIOS.mjs +37 -0
  131. package/dist/mobile/utils/isKeyboardVisible/isKeyboardVisible.cjs +28 -0
  132. package/dist/mobile/utils/isKeyboardVisible/isKeyboardVisible.d.cts +25 -0
  133. package/dist/mobile/utils/isKeyboardVisible/isKeyboardVisible.d.mts +25 -0
  134. package/dist/mobile/utils/isKeyboardVisible/isKeyboardVisible.mjs +28 -0
  135. package/dist/mobile/utils/isServer/isServer.cjs +24 -0
  136. package/dist/mobile/utils/isServer/isServer.d.cts +22 -0
  137. package/dist/mobile/utils/isServer/isServer.d.mts +22 -0
  138. package/dist/mobile/utils/isServer/isServer.mjs +24 -0
  139. package/dist/mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.cjs +71 -0
  140. package/dist/mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.d.cts +64 -0
  141. package/dist/mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.d.mts +64 -0
  142. package/dist/mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.mjs +71 -0
  143. package/dist/utils/buildContext/buildContext.cjs +1 -0
  144. package/dist/utils/buildContext/buildContext.mjs +1 -0
  145. package/dist/utils/mergeProps/mergeProps.cjs +1 -1
  146. package/dist/utils/mergeProps/mergeProps.d.cts +1 -1
  147. package/dist/utils/mergeProps/mergeProps.d.mts +1 -1
  148. package/dist/utils/mergeProps/mergeProps.mjs +1 -1
  149. package/dist/utils/mergeRefs/mergeRefs.cjs +1 -1
  150. package/dist/utils/mergeRefs/mergeRefs.d.cts +1 -1
  151. package/dist/utils/mergeRefs/mergeRefs.d.mts +1 -1
  152. package/dist/utils/mergeRefs/mergeRefs.mjs +1 -1
  153. package/package.json +22 -10
@@ -0,0 +1,89 @@
1
+
2
+ import { CSSProperties } from "react";
3
+ //#region src/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.d.ts
4
+ type UseAvoidKeyboardOptions = {
5
+ /**
6
+ * Base bottom offset in pixels when keyboard is hidden.
7
+ * @default 0
8
+ */
9
+ safeAreaBottom?: number;
10
+ /**
11
+ * Transition duration in milliseconds for smooth animation.
12
+ * @default 200
13
+ */
14
+ transitionDuration?: number;
15
+ /**
16
+ * Transition timing function for the animation.
17
+ * @default 'ease-out'
18
+ */
19
+ transitionTimingFunction?: CSSProperties['transitionTimingFunction'];
20
+ /**
21
+ * If true, the hook will get the initial keyboard height on mount.
22
+ * @default true
23
+ */
24
+ immediate?: boolean;
25
+ };
26
+ type UseAvoidKeyboardResult = {
27
+ /**
28
+ * CSS style object to apply to the fixed bottom element.
29
+ * Contains transform and transition properties.
30
+ */
31
+ style: CSSProperties;
32
+ };
33
+ /**
34
+ * @description
35
+ * `useAvoidKeyboard` is a React hook that helps fixed-bottom elements avoid the on-screen keyboard.
36
+ * It returns a CSS style that can be applied to `position: fixed` elements
37
+ * to smoothly move them above the keyboard when it appears.
38
+ *
39
+ * @param {UseAvoidKeyboardOptions} [options] - Configuration options.
40
+ * @param {number} [options.safeAreaBottom=0] - Base bottom offset in pixels when the keyboard is hidden. Useful for accounting for the iPhone home indicator area.
41
+ * @param {number} [options.transitionDuration=200] - Transition duration in milliseconds for smooth animation.
42
+ * @param {CSSProperties['transitionTimingFunction']} [options.transitionTimingFunction='ease-out'] - Transition timing function for the animation.
43
+ * @param {boolean} [options.immediate=true] - If true, gets the initial keyboard height on mount.
44
+ *
45
+ * @returns {UseAvoidKeyboardResult} An object containing the CSS style for keyboard avoidance.
46
+ * - style `CSSProperties` - CSS style object to apply to the fixed bottom element. Contains `transform` and `transition` properties;
47
+ *
48
+ * @example
49
+ * function FixedBottomCTA() {
50
+ * const { style } = useAvoidKeyboard();
51
+ *
52
+ * return (
53
+ * <div
54
+ * style={{
55
+ * position: 'fixed',
56
+ * bottom: 0,
57
+ * left: 0,
58
+ * right: 0,
59
+ * ...style,
60
+ * }}
61
+ * >
62
+ * <button>Submit</button>
63
+ * </div>
64
+ * );
65
+ * }
66
+ *
67
+ * @example
68
+ * // With safe area bottom offset (e.g., for iPhone home indicator)
69
+ * function FixedBottomCTA() {
70
+ * const { style } = useAvoidKeyboard({ safeAreaBottom: 34 });
71
+ *
72
+ * return (
73
+ * <div
74
+ * style={{
75
+ * position: 'fixed',
76
+ * bottom: 0,
77
+ * left: 0,
78
+ * right: 0,
79
+ * ...style,
80
+ * }}
81
+ * >
82
+ * <button>Submit</button>
83
+ * </div>
84
+ * );
85
+ * }
86
+ */
87
+ declare function useAvoidKeyboard(options?: UseAvoidKeyboardOptions): UseAvoidKeyboardResult;
88
+ //#endregion
89
+ export { useAvoidKeyboard };
@@ -0,0 +1,89 @@
1
+
2
+ import { CSSProperties } from "react";
3
+ //#region src/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.d.ts
4
+ type UseAvoidKeyboardOptions = {
5
+ /**
6
+ * Base bottom offset in pixels when keyboard is hidden.
7
+ * @default 0
8
+ */
9
+ safeAreaBottom?: number;
10
+ /**
11
+ * Transition duration in milliseconds for smooth animation.
12
+ * @default 200
13
+ */
14
+ transitionDuration?: number;
15
+ /**
16
+ * Transition timing function for the animation.
17
+ * @default 'ease-out'
18
+ */
19
+ transitionTimingFunction?: CSSProperties['transitionTimingFunction'];
20
+ /**
21
+ * If true, the hook will get the initial keyboard height on mount.
22
+ * @default true
23
+ */
24
+ immediate?: boolean;
25
+ };
26
+ type UseAvoidKeyboardResult = {
27
+ /**
28
+ * CSS style object to apply to the fixed bottom element.
29
+ * Contains transform and transition properties.
30
+ */
31
+ style: CSSProperties;
32
+ };
33
+ /**
34
+ * @description
35
+ * `useAvoidKeyboard` is a React hook that helps fixed-bottom elements avoid the on-screen keyboard.
36
+ * It returns a CSS style that can be applied to `position: fixed` elements
37
+ * to smoothly move them above the keyboard when it appears.
38
+ *
39
+ * @param {UseAvoidKeyboardOptions} [options] - Configuration options.
40
+ * @param {number} [options.safeAreaBottom=0] - Base bottom offset in pixels when the keyboard is hidden. Useful for accounting for the iPhone home indicator area.
41
+ * @param {number} [options.transitionDuration=200] - Transition duration in milliseconds for smooth animation.
42
+ * @param {CSSProperties['transitionTimingFunction']} [options.transitionTimingFunction='ease-out'] - Transition timing function for the animation.
43
+ * @param {boolean} [options.immediate=true] - If true, gets the initial keyboard height on mount.
44
+ *
45
+ * @returns {UseAvoidKeyboardResult} An object containing the CSS style for keyboard avoidance.
46
+ * - style `CSSProperties` - CSS style object to apply to the fixed bottom element. Contains `transform` and `transition` properties;
47
+ *
48
+ * @example
49
+ * function FixedBottomCTA() {
50
+ * const { style } = useAvoidKeyboard();
51
+ *
52
+ * return (
53
+ * <div
54
+ * style={{
55
+ * position: 'fixed',
56
+ * bottom: 0,
57
+ * left: 0,
58
+ * right: 0,
59
+ * ...style,
60
+ * }}
61
+ * >
62
+ * <button>Submit</button>
63
+ * </div>
64
+ * );
65
+ * }
66
+ *
67
+ * @example
68
+ * // With safe area bottom offset (e.g., for iPhone home indicator)
69
+ * function FixedBottomCTA() {
70
+ * const { style } = useAvoidKeyboard({ safeAreaBottom: 34 });
71
+ *
72
+ * return (
73
+ * <div
74
+ * style={{
75
+ * position: 'fixed',
76
+ * bottom: 0,
77
+ * left: 0,
78
+ * right: 0,
79
+ * ...style,
80
+ * }}
81
+ * >
82
+ * <button>Submit</button>
83
+ * </div>
84
+ * );
85
+ * }
86
+ */
87
+ declare function useAvoidKeyboard(options?: UseAvoidKeyboardOptions): UseAvoidKeyboardResult;
88
+ //#endregion
89
+ export { useAvoidKeyboard };
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { useKeyboardHeight } from "../useKeyboardHeight/useKeyboardHeight.mjs";
3
+ import { useMemo } from "react";
4
+ //#region src/mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.ts
5
+ /**
6
+ * @description
7
+ * `useAvoidKeyboard` is a React hook that helps fixed-bottom elements avoid the on-screen keyboard.
8
+ * It returns a CSS style that can be applied to `position: fixed` elements
9
+ * to smoothly move them above the keyboard when it appears.
10
+ *
11
+ * @param {UseAvoidKeyboardOptions} [options] - Configuration options.
12
+ * @param {number} [options.safeAreaBottom=0] - Base bottom offset in pixels when the keyboard is hidden. Useful for accounting for the iPhone home indicator area.
13
+ * @param {number} [options.transitionDuration=200] - Transition duration in milliseconds for smooth animation.
14
+ * @param {CSSProperties['transitionTimingFunction']} [options.transitionTimingFunction='ease-out'] - Transition timing function for the animation.
15
+ * @param {boolean} [options.immediate=true] - If true, gets the initial keyboard height on mount.
16
+ *
17
+ * @returns {UseAvoidKeyboardResult} An object containing the CSS style for keyboard avoidance.
18
+ * - style `CSSProperties` - CSS style object to apply to the fixed bottom element. Contains `transform` and `transition` properties;
19
+ *
20
+ * @example
21
+ * function FixedBottomCTA() {
22
+ * const { style } = useAvoidKeyboard();
23
+ *
24
+ * return (
25
+ * <div
26
+ * style={{
27
+ * position: 'fixed',
28
+ * bottom: 0,
29
+ * left: 0,
30
+ * right: 0,
31
+ * ...style,
32
+ * }}
33
+ * >
34
+ * <button>Submit</button>
35
+ * </div>
36
+ * );
37
+ * }
38
+ *
39
+ * @example
40
+ * // With safe area bottom offset (e.g., for iPhone home indicator)
41
+ * function FixedBottomCTA() {
42
+ * const { style } = useAvoidKeyboard({ safeAreaBottom: 34 });
43
+ *
44
+ * return (
45
+ * <div
46
+ * style={{
47
+ * position: 'fixed',
48
+ * bottom: 0,
49
+ * left: 0,
50
+ * right: 0,
51
+ * ...style,
52
+ * }}
53
+ * >
54
+ * <button>Submit</button>
55
+ * </div>
56
+ * );
57
+ * }
58
+ */
59
+ function useAvoidKeyboard(options = {}) {
60
+ const { safeAreaBottom = 0, transitionDuration = 200, transitionTimingFunction = "ease-out", immediate = true } = options;
61
+ const { keyboardHeight } = useKeyboardHeight({ immediate });
62
+ return { style: useMemo(() => {
63
+ return {
64
+ transform: `translateY(${keyboardHeight > 0 ? -(keyboardHeight + safeAreaBottom) : 0}px)`,
65
+ transition: `transform ${transitionDuration}ms ${transitionTimingFunction}`
66
+ };
67
+ }, [
68
+ keyboardHeight,
69
+ safeAreaBottom,
70
+ transitionDuration,
71
+ transitionTimingFunction
72
+ ]) };
73
+ }
74
+ //#endregion
75
+ export { useAvoidKeyboard };
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ const require_disableBodyScrollLock = require("../../utils/disableBodyScrollLock/disableBodyScrollLock.cjs");
3
+ const require_enableBodyScrollLock = require("../../utils/enableBodyScrollLock/enableBodyScrollLock.cjs");
4
+ let react = require("react");
5
+ //#region src/mobile/hooks/useBodyScrollLock/useBodyScrollLock.ts
6
+ /**
7
+ * @description
8
+ * `useBodyScrollLock` is a React hook that locks body scroll while the component is mounted.
9
+ * It automatically locks on mount and unlocks on unmount.
10
+ *
11
+ * **Note:** For multiple overlapping modals, use a single lock at the parent level.
12
+ *
13
+ * @example
14
+ * function Modal() {
15
+ * useBodyScrollLock();
16
+ * return <div className="modal">Modal content</div>;
17
+ * }
18
+ *
19
+ * @example
20
+ * // Multiple modals - single lock pattern
21
+ * function BodyScrollLock() {
22
+ * useBodyScrollLock();
23
+ * return null;
24
+ * }
25
+ *
26
+ * function App() {
27
+ * const hasModal = showModal1 || showModal2;
28
+ *
29
+ * return (
30
+ * <>
31
+ * {hasModal && <BodyScrollLock />}
32
+ * {showModal1 && <Modal1 />}
33
+ * {showModal2 && <Modal2 />}
34
+ * </>
35
+ * );
36
+ * }
37
+ */
38
+ function useBodyScrollLock() {
39
+ (0, react.useEffect)(() => {
40
+ require_enableBodyScrollLock.enableBodyScrollLock();
41
+ return () => {
42
+ require_disableBodyScrollLock.disableBodyScrollLock();
43
+ };
44
+ }, []);
45
+ }
46
+ //#endregion
47
+ exports.useBodyScrollLock = useBodyScrollLock;
@@ -0,0 +1,37 @@
1
+
2
+ //#region src/mobile/hooks/useBodyScrollLock/useBodyScrollLock.d.ts
3
+ /**
4
+ * @description
5
+ * `useBodyScrollLock` is a React hook that locks body scroll while the component is mounted.
6
+ * It automatically locks on mount and unlocks on unmount.
7
+ *
8
+ * **Note:** For multiple overlapping modals, use a single lock at the parent level.
9
+ *
10
+ * @example
11
+ * function Modal() {
12
+ * useBodyScrollLock();
13
+ * return <div className="modal">Modal content</div>;
14
+ * }
15
+ *
16
+ * @example
17
+ * // Multiple modals - single lock pattern
18
+ * function BodyScrollLock() {
19
+ * useBodyScrollLock();
20
+ * return null;
21
+ * }
22
+ *
23
+ * function App() {
24
+ * const hasModal = showModal1 || showModal2;
25
+ *
26
+ * return (
27
+ * <>
28
+ * {hasModal && <BodyScrollLock />}
29
+ * {showModal1 && <Modal1 />}
30
+ * {showModal2 && <Modal2 />}
31
+ * </>
32
+ * );
33
+ * }
34
+ */
35
+ declare function useBodyScrollLock(): void;
36
+ //#endregion
37
+ export { useBodyScrollLock };
@@ -0,0 +1,37 @@
1
+
2
+ //#region src/mobile/hooks/useBodyScrollLock/useBodyScrollLock.d.ts
3
+ /**
4
+ * @description
5
+ * `useBodyScrollLock` is a React hook that locks body scroll while the component is mounted.
6
+ * It automatically locks on mount and unlocks on unmount.
7
+ *
8
+ * **Note:** For multiple overlapping modals, use a single lock at the parent level.
9
+ *
10
+ * @example
11
+ * function Modal() {
12
+ * useBodyScrollLock();
13
+ * return <div className="modal">Modal content</div>;
14
+ * }
15
+ *
16
+ * @example
17
+ * // Multiple modals - single lock pattern
18
+ * function BodyScrollLock() {
19
+ * useBodyScrollLock();
20
+ * return null;
21
+ * }
22
+ *
23
+ * function App() {
24
+ * const hasModal = showModal1 || showModal2;
25
+ *
26
+ * return (
27
+ * <>
28
+ * {hasModal && <BodyScrollLock />}
29
+ * {showModal1 && <Modal1 />}
30
+ * {showModal2 && <Modal2 />}
31
+ * </>
32
+ * );
33
+ * }
34
+ */
35
+ declare function useBodyScrollLock(): void;
36
+ //#endregion
37
+ export { useBodyScrollLock };
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ import { disableBodyScrollLock } from "../../utils/disableBodyScrollLock/disableBodyScrollLock.mjs";
3
+ import { enableBodyScrollLock } from "../../utils/enableBodyScrollLock/enableBodyScrollLock.mjs";
4
+ import { useEffect } from "react";
5
+ //#region src/mobile/hooks/useBodyScrollLock/useBodyScrollLock.ts
6
+ /**
7
+ * @description
8
+ * `useBodyScrollLock` is a React hook that locks body scroll while the component is mounted.
9
+ * It automatically locks on mount and unlocks on unmount.
10
+ *
11
+ * **Note:** For multiple overlapping modals, use a single lock at the parent level.
12
+ *
13
+ * @example
14
+ * function Modal() {
15
+ * useBodyScrollLock();
16
+ * return <div className="modal">Modal content</div>;
17
+ * }
18
+ *
19
+ * @example
20
+ * // Multiple modals - single lock pattern
21
+ * function BodyScrollLock() {
22
+ * useBodyScrollLock();
23
+ * return null;
24
+ * }
25
+ *
26
+ * function App() {
27
+ * const hasModal = showModal1 || showModal2;
28
+ *
29
+ * return (
30
+ * <>
31
+ * {hasModal && <BodyScrollLock />}
32
+ * {showModal1 && <Modal1 />}
33
+ * {showModal2 && <Modal2 />}
34
+ * </>
35
+ * );
36
+ * }
37
+ */
38
+ function useBodyScrollLock() {
39
+ useEffect(() => {
40
+ enableBodyScrollLock();
41
+ return () => {
42
+ disableBodyScrollLock();
43
+ };
44
+ }, []);
45
+ }
46
+ //#endregion
47
+ export { useBodyScrollLock };
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ const require_subscribeKeyboardHeight = require("../../utils/subscribeKeyboardHeight/subscribeKeyboardHeight.cjs");
3
+ let react = require("react");
4
+ //#region src/mobile/hooks/useKeyboardHeight/useKeyboardHeight.ts
5
+ /**
6
+ * @description
7
+ * `useKeyboardHeight` is a React hook that tracks the on-screen keyboard height.
8
+ * It returns the current keyboard height in pixels, which updates automatically
9
+ * when the keyboard appears, disappears, or changes size.
10
+ *
11
+ * @param {UseKeyboardHeightOptions} [options] - Configuration options.
12
+ * @param {boolean} [options.immediate=true] - If true, gets the initial keyboard height on mount.
13
+ *
14
+ * @returns {UseKeyboardHeightResult} An object containing the current keyboard height.
15
+ * - keyboardHeight `number` - The current keyboard height in pixels. 0 when the keyboard is hidden;
16
+ *
17
+ * @example
18
+ * function ChatInput() {
19
+ * const { keyboardHeight } = useKeyboardHeight();
20
+ *
21
+ * return (
22
+ * <div style={{ paddingBottom: `${keyboardHeight}px` }}>
23
+ * <input type="text" placeholder="Type a message..." />
24
+ * </div>
25
+ * );
26
+ * }
27
+ */
28
+ function useKeyboardHeight(options = {}) {
29
+ const { immediate = true } = options;
30
+ const [keyboardHeight, setKeyboardHeight] = (0, react.useState)(0);
31
+ (0, react.useEffect)(function subscribeToKeyboardHeight() {
32
+ const { unsubscribe } = require_subscribeKeyboardHeight.subscribeKeyboardHeight({
33
+ callback: setKeyboardHeight,
34
+ immediate
35
+ });
36
+ return unsubscribe;
37
+ }, [immediate]);
38
+ return { keyboardHeight };
39
+ }
40
+ //#endregion
41
+ exports.useKeyboardHeight = useKeyboardHeight;
@@ -0,0 +1,41 @@
1
+
2
+ //#region src/mobile/hooks/useKeyboardHeight/useKeyboardHeight.d.ts
3
+ type UseKeyboardHeightOptions = {
4
+ /**
5
+ * If true, the hook will get the initial keyboard height on mount.
6
+ * @default true
7
+ */
8
+ immediate?: boolean;
9
+ };
10
+ type UseKeyboardHeightResult = {
11
+ /**
12
+ * The current keyboard height in pixels.
13
+ */
14
+ keyboardHeight: number;
15
+ };
16
+ /**
17
+ * @description
18
+ * `useKeyboardHeight` is a React hook that tracks the on-screen keyboard height.
19
+ * It returns the current keyboard height in pixels, which updates automatically
20
+ * when the keyboard appears, disappears, or changes size.
21
+ *
22
+ * @param {UseKeyboardHeightOptions} [options] - Configuration options.
23
+ * @param {boolean} [options.immediate=true] - If true, gets the initial keyboard height on mount.
24
+ *
25
+ * @returns {UseKeyboardHeightResult} An object containing the current keyboard height.
26
+ * - keyboardHeight `number` - The current keyboard height in pixels. 0 when the keyboard is hidden;
27
+ *
28
+ * @example
29
+ * function ChatInput() {
30
+ * const { keyboardHeight } = useKeyboardHeight();
31
+ *
32
+ * return (
33
+ * <div style={{ paddingBottom: `${keyboardHeight}px` }}>
34
+ * <input type="text" placeholder="Type a message..." />
35
+ * </div>
36
+ * );
37
+ * }
38
+ */
39
+ declare function useKeyboardHeight(options?: UseKeyboardHeightOptions): UseKeyboardHeightResult;
40
+ //#endregion
41
+ export { useKeyboardHeight };
@@ -0,0 +1,41 @@
1
+
2
+ //#region src/mobile/hooks/useKeyboardHeight/useKeyboardHeight.d.ts
3
+ type UseKeyboardHeightOptions = {
4
+ /**
5
+ * If true, the hook will get the initial keyboard height on mount.
6
+ * @default true
7
+ */
8
+ immediate?: boolean;
9
+ };
10
+ type UseKeyboardHeightResult = {
11
+ /**
12
+ * The current keyboard height in pixels.
13
+ */
14
+ keyboardHeight: number;
15
+ };
16
+ /**
17
+ * @description
18
+ * `useKeyboardHeight` is a React hook that tracks the on-screen keyboard height.
19
+ * It returns the current keyboard height in pixels, which updates automatically
20
+ * when the keyboard appears, disappears, or changes size.
21
+ *
22
+ * @param {UseKeyboardHeightOptions} [options] - Configuration options.
23
+ * @param {boolean} [options.immediate=true] - If true, gets the initial keyboard height on mount.
24
+ *
25
+ * @returns {UseKeyboardHeightResult} An object containing the current keyboard height.
26
+ * - keyboardHeight `number` - The current keyboard height in pixels. 0 when the keyboard is hidden;
27
+ *
28
+ * @example
29
+ * function ChatInput() {
30
+ * const { keyboardHeight } = useKeyboardHeight();
31
+ *
32
+ * return (
33
+ * <div style={{ paddingBottom: `${keyboardHeight}px` }}>
34
+ * <input type="text" placeholder="Type a message..." />
35
+ * </div>
36
+ * );
37
+ * }
38
+ */
39
+ declare function useKeyboardHeight(options?: UseKeyboardHeightOptions): UseKeyboardHeightResult;
40
+ //#endregion
41
+ export { useKeyboardHeight };
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { subscribeKeyboardHeight } from "../../utils/subscribeKeyboardHeight/subscribeKeyboardHeight.mjs";
3
+ import { useEffect, useState } from "react";
4
+ //#region src/mobile/hooks/useKeyboardHeight/useKeyboardHeight.ts
5
+ /**
6
+ * @description
7
+ * `useKeyboardHeight` is a React hook that tracks the on-screen keyboard height.
8
+ * It returns the current keyboard height in pixels, which updates automatically
9
+ * when the keyboard appears, disappears, or changes size.
10
+ *
11
+ * @param {UseKeyboardHeightOptions} [options] - Configuration options.
12
+ * @param {boolean} [options.immediate=true] - If true, gets the initial keyboard height on mount.
13
+ *
14
+ * @returns {UseKeyboardHeightResult} An object containing the current keyboard height.
15
+ * - keyboardHeight `number` - The current keyboard height in pixels. 0 when the keyboard is hidden;
16
+ *
17
+ * @example
18
+ * function ChatInput() {
19
+ * const { keyboardHeight } = useKeyboardHeight();
20
+ *
21
+ * return (
22
+ * <div style={{ paddingBottom: `${keyboardHeight}px` }}>
23
+ * <input type="text" placeholder="Type a message..." />
24
+ * </div>
25
+ * );
26
+ * }
27
+ */
28
+ function useKeyboardHeight(options = {}) {
29
+ const { immediate = true } = options;
30
+ const [keyboardHeight, setKeyboardHeight] = useState(0);
31
+ useEffect(function subscribeToKeyboardHeight() {
32
+ const { unsubscribe } = subscribeKeyboardHeight({
33
+ callback: setKeyboardHeight,
34
+ immediate
35
+ });
36
+ return unsubscribe;
37
+ }, [immediate]);
38
+ return { keyboardHeight };
39
+ }
40
+ //#endregion
41
+ export { useKeyboardHeight };
@@ -0,0 +1,88 @@
1
+ "use client";
2
+ const require_isServer = require("../../utils/isServer/isServer.cjs");
3
+ let react = require("react");
4
+ //#region src/mobile/hooks/useNetworkStatus/useNetworkStatus.ts
5
+ /**
6
+ * @description
7
+ * `useNetworkStatus` is a React hook that provides access to the Network Information API.
8
+ * It provides raw network connection data. Returns undefined for all properties
9
+ * if the API is not supported (e.g., Safari, Firefox).
10
+ *
11
+ * **Browser Support**:
12
+ * - Chrome/Edge (Android): Full support
13
+ * - Chrome/Edge (Desktop): Partial support (effectiveType, downlink, rtt, saveData)
14
+ * - Firefox: Not supported
15
+ * - Safari: Not supported
16
+ *
17
+ * @returns {NetworkStatus} Network status information
18
+ * - `effectiveType` - Connection quality: 'slow-2g' | '2g' | '3g' | '4g'
19
+ * - `type` - Physical connection: 'wifi' | 'cellular' | 'ethernet' | etc.
20
+ * - `downlink` - Downlink speed in Mbps
21
+ * - `rtt` - Round-trip time in milliseconds
22
+ * - `saveData` - User's data saver preference
23
+ *
24
+ * @example
25
+ * function AdaptiveImage() {
26
+ * const { effectiveType, saveData } = useNetworkStatus();
27
+ *
28
+ * // Determine quality based on your app's needs
29
+ * const useHighQuality = effectiveType === '4g' && !saveData;
30
+ *
31
+ * return (
32
+ * <img
33
+ * src={useHighQuality ? 'high-res.jpg' : 'low-res.jpg'}
34
+ * alt="Content"
35
+ * />
36
+ * );
37
+ * }
38
+ *
39
+ * @example
40
+ * function VideoPlayer() {
41
+ * const { type, downlink } = useNetworkStatus();
42
+ *
43
+ * // Custom logic: only autoplay on wifi with good bandwidth
44
+ * const shouldAutoplay = type === 'wifi' && (downlink ?? 0) > 5;
45
+ *
46
+ * return <video src="video.mp4" autoPlay={shouldAutoplay} />;
47
+ * }
48
+ *
49
+ * @see https://wicg.github.io/netinfo/
50
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API
51
+ */
52
+ function useNetworkStatus() {
53
+ const [networkStatus, setNetworkStatus] = (0, react.useState)(getNetworkStatus);
54
+ (0, react.useEffect)(function subscribeToNetworkChanges() {
55
+ if (require_isServer.isServer()) return;
56
+ const connection = getNavigatorConnection();
57
+ if (connection == null) return;
58
+ function updateNetworkStatus() {
59
+ setNetworkStatus(getNetworkStatus());
60
+ }
61
+ connection.addEventListener("change", updateNetworkStatus);
62
+ return function cleanup() {
63
+ connection.removeEventListener("change", updateNetworkStatus);
64
+ };
65
+ }, []);
66
+ return networkStatus;
67
+ }
68
+ function getNavigatorConnection() {
69
+ if (require_isServer.isServer() || !("connection" in navigator)) return null;
70
+ try {
71
+ return navigator.connection ?? null;
72
+ } catch {
73
+ return null;
74
+ }
75
+ }
76
+ function getNetworkStatus() {
77
+ const connection = getNavigatorConnection();
78
+ if (connection == null) return {};
79
+ return {
80
+ effectiveType: connection.effectiveType,
81
+ type: connection.type,
82
+ downlink: connection.downlink,
83
+ rtt: connection.rtt,
84
+ saveData: connection.saveData
85
+ };
86
+ }
87
+ //#endregion
88
+ exports.useNetworkStatus = useNetworkStatus;