Skip to content

Commit d328d9d

Browse files
committed
main 🧊 fix double click
1 parent 89bca0a commit d328d9d

File tree

9 files changed

+20
-11
lines changed

9 files changed

+20
-11
lines changed

‎packages/core/src/bundle/hooks/useActiveElement/useActiveElement.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { useEffect, useState } from 'react';
88
*
99
* @example
1010
* const activeElement = useActiveElement();
11+
*
12+
* @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useActiveElement.html}
1113
*/
1214
export const useActiveElement = () => {
1315
const [activeElement, setActiveElement] = useState(null);

‎packages/core/src/bundle/hooks/useDoubleClick/useDoubleClick.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const DEFAULT_THRESHOLD_TIME = 300;
2424
*
2525
* @example
2626
* const ref = useDoubleClick(() => console.log('double clicked'));
27+
*
28+
* @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useDoubleClick.html}
2729
*/
2830
export const useDoubleClick = (...params) => {
2931
const target = isTarget(params[0]) ? params[0] : undefined;

‎packages/core/src/bundle/hooks/useWindowFocus/useWindowFocus.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { useEffect, useState } from 'react';
88
*
99
* @example
1010
* const focused = useWindowFocus();
11+
*
12+
* @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useWindowFocus.html}
1113
*/
1214
export const useWindowFocus = () => {
1315
const [focused, setFocused] = useState(false);

‎packages/core/src/hooks/useActiveElement/useActiveElement.demo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ const Demo = () => {
66

77
return (
88
<>
9-
<div className='grid grid-cols-2 gap-1'>
9+
<div className='grid grid-cols-2 gap-1 mt-1'>
1010
{Array.from({ length: 6 }, (_, i) => i + 1).map((id) => (
1111
<input
1212
key={id}
13-
className='rounded border p-2'
13+
className='rounded border p-2 w-min-content'
1414
data-id={String(id)}
1515
type='text'
1616
placeholder={String(id)}

‎packages/core/src/hooks/useActiveElement/useActiveElement.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { useEffect, useState } from 'react';
99
*
1010
* @example
1111
* const activeElement = useActiveElement();
12+
*
13+
* @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useActiveElement.html}
1214
*/
1315
export const useActiveElement = <ActiveElement extends HTMLElement>() => {
1416
const [activeElement, setActiveElement] = useState<ActiveElement | null>(null);

‎packages/core/src/hooks/useDoubleClick/useDoubleClick.demo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { useDoubleClick } from './useDoubleClick';
33

44
const Demo = () => {
55
const counter = useCounter();
6-
const doubleClick = useDoubleClick<HTMLButtonElement>(() => counter.inc());
6+
const doubleClickRef = useDoubleClick<HTMLButtonElement>(() => counter.inc());
77

88
return (
99
<>
1010
<p>
11-
Double clicked: <code>{counter.value}</code> times
11+
Double clicked <code>{counter.value}</code> times
1212
</p>
13-
<button ref={doubleClick.ref} type="button">
13+
<button ref={doubleClickRef} type="button">
1414
Double click me
1515
</button>
1616
</>

‎packages/core/src/hooks/useDoubleClick/useDoubleClick.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ export interface UseDoubleClick {
2929
callback: (event: DoubleClickEvents) => void,
3030
options?: UseDoubleClickOptions,
3131
target?: never
32-
): {
33-
ref: StateRef<Target>;
34-
clicked: boolean;
35-
};
32+
): StateRef<Target>;
3633
}
3734

3835
const DEFAULT_THRESHOLD_TIME = 300;
@@ -59,6 +56,8 @@ const DEFAULT_THRESHOLD_TIME = 300;
5956
*
6057
* @example
6158
* const ref = useDoubleClick(() => console.log('double clicked'));
59+
*
60+
* @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useDoubleClick.html}
6261
*/
6362
export const useDoubleClick = ((...params: any[]): any => {
6463
const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;

‎packages/core/src/hooks/useWindowFocus/useWindowFocus.demo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const Demo = () => {
55

66
return (
77
<p>
8-
{windowFocused && '💡 Click somewhere outside of the document to unfocus.'}
9-
{!windowFocused && 'ℹ Tab is unfocused'}
8+
{windowFocused && <>💡 Click somewhere outside of the document to <code>unfocus</code></>}
9+
{!windowFocused && <>ℹ Tab is <code>unfocused</code></>}
1010
</p>
1111
);
1212
};

‎packages/core/src/hooks/useWindowFocus/useWindowFocus.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { useEffect, useState } from 'react';
99
*
1010
* @example
1111
* const focused = useWindowFocus();
12+
*
13+
* @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useWindowFocus.html}
1214
*/
1315
export const useWindowFocus = () => {
1416
const [focused, setFocused] = useState(false);

0 commit comments

Comments
 (0)