This commit is contained in:
eewing
2026-02-17 14:10:16 -06:00
parent 2bca5834c5
commit cf73cd3b4c
11246 changed files with 1690552 additions and 0 deletions
@@ -0,0 +1,20 @@
import { ActiveElement, } from "../active-element/active-element.svelte.js";
import { extract } from "../extract/extract.svelte.js";
/**
* Tracks whether the focus is within a target element.
* @see {@link https://runed.dev/docs/utilities/is-focus-within}
*/
export class IsFocusWithin {
#node;
#activeElement;
constructor(node, options = {}) {
this.#node = node;
this.#activeElement = new ActiveElement(options);
}
current = $derived.by(() => {
const node = extract(this.#node);
if (node == null)
return false;
return node.contains(this.#activeElement.current);
});
}