react-simplikit 0.0.7 → 0.0.8
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/dist/components/SwitchCase/index.d.ts +1 -1
- package/dist/hooks/useAsyncEffect/index.d.ts +1 -1
- package/dist/hooks/useImpressionRef/index.d.ts +4 -4
- package/dist/hooks/useIntersectionObserver/index.d.ts +3 -1
- package/dist/hooks/useThrottle/index.d.ts +1 -0
- package/esm/components/SwitchCase/index.d.mts +1 -1
- package/esm/hooks/useAsyncEffect/index.d.mts +1 -1
- package/esm/hooks/useImpressionRef/index.d.mts +4 -4
- package/esm/hooks/useIntersectionObserver/index.d.mts +3 -1
- package/esm/hooks/useThrottle/index.d.mts +1 -0
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ type Props<Case> = {
|
|
|
19
19
|
* @param {Record<string | number, () => JSX.Element>} caseBy - An object that maps values to
|
|
20
20
|
* components to render. The keys represent possible values, and the values are functions returning
|
|
21
21
|
* the corresponding components.
|
|
22
|
-
* @param {() => JSX.Element} defaultComponent - The component to render if `value` does not match
|
|
22
|
+
* @param {() => JSX.Element} [defaultComponent] - The component to render if `value` does not match
|
|
23
23
|
* any key in `caseBy`.
|
|
24
24
|
*
|
|
25
25
|
* @returns {JSX.Element} A React component that conditionally renders based on cases.
|
|
@@ -5,7 +5,7 @@ import { DependencyList } from 'react';
|
|
|
5
5
|
* `useAsyncEffect` is a custom hook for handling asynchronous side effects in React components.
|
|
6
6
|
* It follows the same cleanup pattern as `useEffect` while ensuring async operations are handled safely.
|
|
7
7
|
*
|
|
8
|
-
* @param {() => Promise<void | (() => void)>}
|
|
8
|
+
* @param {() => Promise<void | (() => void)>} effect - An asynchronous function executed in the `useEffect` pattern.
|
|
9
9
|
* This function can optionally return a cleanup function.
|
|
10
10
|
* @param {DependencyList} [deps] - A dependency array.
|
|
11
11
|
* The effect will re-run whenever any value in this array changes. If omitted, it runs only once when the component mounts.
|
|
@@ -11,10 +11,10 @@ type UseImpressionRefOptions = Partial<{
|
|
|
11
11
|
* This hook uses `IntersectionObserver` and the `Visibility API` to track the element's visibility.
|
|
12
12
|
*
|
|
13
13
|
* @param {UseImpressionRefOptions} options - Options for tracking the element's visibility.
|
|
14
|
-
* @param {() => void} options.onImpressionStart - Callback function executed when the element enters the view
|
|
15
|
-
* @param {() => void} options.onImpressionEnd - Callback function executed when the element exits the view
|
|
16
|
-
* @param {number} options.timeThreshold - Minimum time the element must be visible (in milliseconds)
|
|
17
|
-
* @param {number} options.areaThreshold - Minimum ratio of the element that must be visible (0 to 1)
|
|
14
|
+
* @param {() => void} [options.onImpressionStart] - Callback function executed when the element enters the view
|
|
15
|
+
* @param {() => void} [options.onImpressionEnd] - Callback function executed when the element exits the view
|
|
16
|
+
* @param {number} [options.timeThreshold=0] - Minimum time the element must be visible (in milliseconds)
|
|
17
|
+
* @param {number} [options.areaThreshold=0] - Minimum ratio of the element that must be visible (0 to 1)
|
|
18
18
|
* @param {string} options.rootMargin - Margin to adjust the detection area
|
|
19
19
|
*
|
|
20
20
|
* @returns {(element: Element | null) => void} A function to set the element. Attach this function to the `ref` attribute, and the callbacks will be executed whenever the element's visibility changes.
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* @param {(entry: IntersectionObserverEntry) => void} callback - A callback function that is executed when the visibility of the element changes.
|
|
7
7
|
* You can check `entry.isIntersecting` to determine if the element is in view.
|
|
8
8
|
* @param {IntersectionObserverInit} options - Options for the `IntersectionObserver`.
|
|
9
|
-
*
|
|
9
|
+
* @param {boolean} [options.root] - The element that is used as the viewport for checking visibility of the target.
|
|
10
|
+
* @param {string} [options.rootMargin] - Margin around the root.
|
|
11
|
+
* @param {number | number[]} [options.threshold] - Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed.
|
|
10
12
|
*
|
|
11
13
|
* @returns {(element: Element | null) => void} A function to set the element. Attach this function to the `ref` attribute, and the `callback` will be executed whenever the element's visibility changes.
|
|
12
14
|
*
|
|
@@ -24,6 +24,7 @@ declare function throttle<F extends (...args: any[]) => void>(func: F, throttleM
|
|
|
24
24
|
* @param {F} callback - The function to be throttled.
|
|
25
25
|
* @param {number} wait - The number of milliseconds to throttle invocations to.
|
|
26
26
|
* @param {{ edges?: Array<'leading' | 'trailing'> }} [options] - Options to control the behavior of the throttle.
|
|
27
|
+
* @param {Array<'leading' | 'trailing'>} [options.edges=['leading', 'trailing']] - An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both.
|
|
27
28
|
* @returns {F & { cancel: () => void }} - Returns the throttled function with a `cancel` method to cancel pending executions.
|
|
28
29
|
*
|
|
29
30
|
* @example
|
|
@@ -19,7 +19,7 @@ type Props<Case> = {
|
|
|
19
19
|
* @param {Record<string | number, () => JSX.Element>} caseBy - An object that maps values to
|
|
20
20
|
* components to render. The keys represent possible values, and the values are functions returning
|
|
21
21
|
* the corresponding components.
|
|
22
|
-
* @param {() => JSX.Element} defaultComponent - The component to render if `value` does not match
|
|
22
|
+
* @param {() => JSX.Element} [defaultComponent] - The component to render if `value` does not match
|
|
23
23
|
* any key in `caseBy`.
|
|
24
24
|
*
|
|
25
25
|
* @returns {JSX.Element} A React component that conditionally renders based on cases.
|
|
@@ -5,7 +5,7 @@ import { DependencyList } from 'react';
|
|
|
5
5
|
* `useAsyncEffect` is a custom hook for handling asynchronous side effects in React components.
|
|
6
6
|
* It follows the same cleanup pattern as `useEffect` while ensuring async operations are handled safely.
|
|
7
7
|
*
|
|
8
|
-
* @param {() => Promise<void | (() => void)>}
|
|
8
|
+
* @param {() => Promise<void | (() => void)>} effect - An asynchronous function executed in the `useEffect` pattern.
|
|
9
9
|
* This function can optionally return a cleanup function.
|
|
10
10
|
* @param {DependencyList} [deps] - A dependency array.
|
|
11
11
|
* The effect will re-run whenever any value in this array changes. If omitted, it runs only once when the component mounts.
|
|
@@ -11,10 +11,10 @@ type UseImpressionRefOptions = Partial<{
|
|
|
11
11
|
* This hook uses `IntersectionObserver` and the `Visibility API` to track the element's visibility.
|
|
12
12
|
*
|
|
13
13
|
* @param {UseImpressionRefOptions} options - Options for tracking the element's visibility.
|
|
14
|
-
* @param {() => void} options.onImpressionStart - Callback function executed when the element enters the view
|
|
15
|
-
* @param {() => void} options.onImpressionEnd - Callback function executed when the element exits the view
|
|
16
|
-
* @param {number} options.timeThreshold - Minimum time the element must be visible (in milliseconds)
|
|
17
|
-
* @param {number} options.areaThreshold - Minimum ratio of the element that must be visible (0 to 1)
|
|
14
|
+
* @param {() => void} [options.onImpressionStart] - Callback function executed when the element enters the view
|
|
15
|
+
* @param {() => void} [options.onImpressionEnd] - Callback function executed when the element exits the view
|
|
16
|
+
* @param {number} [options.timeThreshold=0] - Minimum time the element must be visible (in milliseconds)
|
|
17
|
+
* @param {number} [options.areaThreshold=0] - Minimum ratio of the element that must be visible (0 to 1)
|
|
18
18
|
* @param {string} options.rootMargin - Margin to adjust the detection area
|
|
19
19
|
*
|
|
20
20
|
* @returns {(element: Element | null) => void} A function to set the element. Attach this function to the `ref` attribute, and the callbacks will be executed whenever the element's visibility changes.
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* @param {(entry: IntersectionObserverEntry) => void} callback - A callback function that is executed when the visibility of the element changes.
|
|
7
7
|
* You can check `entry.isIntersecting` to determine if the element is in view.
|
|
8
8
|
* @param {IntersectionObserverInit} options - Options for the `IntersectionObserver`.
|
|
9
|
-
*
|
|
9
|
+
* @param {boolean} [options.root] - The element that is used as the viewport for checking visibility of the target.
|
|
10
|
+
* @param {string} [options.rootMargin] - Margin around the root.
|
|
11
|
+
* @param {number | number[]} [options.threshold] - Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed.
|
|
10
12
|
*
|
|
11
13
|
* @returns {(element: Element | null) => void} A function to set the element. Attach this function to the `ref` attribute, and the `callback` will be executed whenever the element's visibility changes.
|
|
12
14
|
*
|
|
@@ -24,6 +24,7 @@ declare function throttle<F extends (...args: any[]) => void>(func: F, throttleM
|
|
|
24
24
|
* @param {F} callback - The function to be throttled.
|
|
25
25
|
* @param {number} wait - The number of milliseconds to throttle invocations to.
|
|
26
26
|
* @param {{ edges?: Array<'leading' | 'trailing'> }} [options] - Options to control the behavior of the throttle.
|
|
27
|
+
* @param {Array<'leading' | 'trailing'>} [options.edges=['leading', 'trailing']] - An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both.
|
|
27
28
|
* @returns {F & { cancel: () => void }} - Returns the throttled function with a `cancel` method to cancel pending executions.
|
|
28
29
|
*
|
|
29
30
|
* @example
|