@zag-js/dom-utils
Advanced tools
Comparing version 0.0.0-dev-20221005155029 to 0.0.0-dev-20221015064943
@@ -209,2 +209,3 @@ import { JSX } from '@zag-js/types'; | ||
getById: <T_1 = HTMLElement>(ctx: Ctx, id: string) => T_1 | null; | ||
createEmitter: (ctx: Ctx, ns: string, target: HTMLElement | null) => (evt: string, detail: Record<string, any>, options?: Omit<CustomEventInit<EventInit>, "detail">) => void; | ||
} & T; | ||
@@ -211,0 +212,0 @@ declare function contains(parent: HTMLElement | EventTarget | null | undefined, child: HTMLElement | EventTarget | null): boolean; |
@@ -297,3 +297,17 @@ "use strict"; | ||
getActiveElement: (ctx) => dom.getDoc(ctx).activeElement, | ||
getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id) | ||
getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id), | ||
createEmitter: (ctx, ns, target) => { | ||
const win = dom.getWin(ctx); | ||
if (!target) { | ||
throw new Error("[dom/create-emit] Expected an element but got undefined"); | ||
} | ||
return (evt, detail, options) => { | ||
const event = new win.CustomEvent(`zag:${ns}:${evt}`, { | ||
detail, | ||
bubbles: (options == null ? void 0 : options.bubbles) || true, | ||
cancelable: options == null ? void 0 : options.cancelable | ||
}); | ||
target.dispatchEvent(event); | ||
}; | ||
} | ||
}; | ||
@@ -300,0 +314,0 @@ return { |
{ | ||
"name": "@zag-js/dom-utils", | ||
"version": "0.0.0-dev-20221005155029", | ||
"version": "0.0.0-dev-20221015064943", | ||
"description": "", | ||
@@ -28,6 +28,6 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@zag-js/types": "0.0.0-dev-20221005155029" | ||
"@zag-js/types": "0.2.7" | ||
}, | ||
"devDependencies": { | ||
"@zag-js/utils": "0.0.0-dev-20221005155029" | ||
"@zag-js/utils": "0.1.6" | ||
}, | ||
@@ -34,0 +34,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83946
2425
+ Added@zag-js/types@0.2.7(transitive)
- Removed@zag-js/types@0.0.0-dev-20221005155029(transitive)
Updated@zag-js/types@0.2.7