1- import type { RefObject } from " react" ;
1+ import type { RefObject } from ' react' ;
22
3- export const targetSymbol = Symbol ( " target" ) ;
3+ export const targetSymbol = Symbol ( ' target' ) ;
44
55export type Target = ( ( ) => Element ) | string | Document | Element | Window ;
66interface StateRef < Value > {
@@ -18,15 +18,15 @@ export type HookTarget =
1818 } ;
1919
2020const getElement = ( target : HookTarget ) => {
21- if ( " current" in target ) {
21+ if ( ' current' in target ) {
2222 return target . current ;
2323 }
2424
25- if ( typeof target . value === " function" ) {
25+ if ( typeof target . value === ' function' ) {
2626 return target . value ( ) ;
2727 }
2828
29- if ( typeof target . value === " string" ) {
29+ if ( typeof target . value === ' string' ) {
3030 return document . querySelector ( target . value ) ;
3131 }
3232
@@ -47,17 +47,15 @@ const getElement = (target: HookTarget) => {
4747
4848export const target = ( target : Target ) => ( {
4949 value : target ,
50- type : targetSymbol ,
50+ type : targetSymbol
5151} ) ;
5252
5353export const isTarget = ( target : HookTarget ) =>
54- ( typeof target === "object" &&
55- ( "current" in target ||
56- ( target && ( target as any ) . type === targetSymbol ) ) ) ||
57- ( typeof target === "function" && "state" in target && "current" in target ) ;
54+ ( typeof target === 'object' &&
55+ ( 'current' in target || ( target && ( target as any ) . type === targetSymbol ) ) ) ||
56+ ( typeof target === 'function' && 'state' in target && 'current' in target ) ;
5857
59- export const getRefState = ( target ?: HookTarget ) =>
60- target && "state" in target && target . state ;
58+ export const getRefState = ( target ?: HookTarget ) => target && 'state' in target && target . state ;
6159
6260isTarget . wrap = target ;
6361isTarget . getElement = getElement ;
0 commit comments