File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed
Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change 1- import { getActiveElement , getDocument } from "@zag-js/dom-query"
1+ import { getActiveElement , getDocument , isActiveElement } from "@zag-js/dom-query"
22import type { Scope } from "./types"
33
44export function createScope ( props : Pick < Scope , "id" | "ids" | "getRootNode" > ) {
55 const getRootNode = ( ) => ( props . getRootNode ?.( ) ?? document ) as Document | ShadowRoot
66 const getDoc = ( ) => getDocument ( getRootNode ( ) )
77 const getWin = ( ) => getDoc ( ) . defaultView ?? window
88 const getActiveElementFn = ( ) => getActiveElement ( getRootNode ( ) )
9- const isActiveElement = ( elem : HTMLElement | null ) => elem === getActiveElementFn ( )
109 const getById = < T extends Element = HTMLElement > ( id : string ) => getRootNode ( ) . getElementById ( id ) as T | null
1110 return {
1211 ...props ,
Original file line number Diff line number Diff line change 11import { setElementValue } from "./form"
2- import { getActiveElement , getDocument } from "./node"
2+ import { getActiveElement , getDocument , isActiveElement } from "./node"
33import type { HTMLElementWithValue } from "./types"
44
55export interface ScopeContext {
@@ -12,7 +12,7 @@ export function createScope<T>(methods: T) {
1212 getDoc : ( ctx : ScopeContext ) => getDocument ( dom . getRootNode ( ctx ) ) ,
1313 getWin : ( ctx : ScopeContext ) => dom . getDoc ( ctx ) . defaultView ?? window ,
1414 getActiveElement : ( ctx : ScopeContext ) => getActiveElement ( dom . getRootNode ( ctx ) ) ,
15- isActiveElement : ( ctx : ScopeContext , elem : HTMLElement | null ) => elem === dom . getActiveElement ( ctx ) ,
15+ isActiveElement,
1616 getById : < T extends Element = HTMLElement > ( ctx : ScopeContext , id : string ) =>
1717 dom . getRootNode ( ctx ) . getElementById ( id ) as T | null ,
1818 setValue : < T extends HTMLElementWithValue > ( elem : T | null , value : string | number | null | undefined ) => {
You can’t perform that action at this time.
0 commit comments