INIT
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
export * from "./is-focus-within.svelte.js";
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from "./is-focus-within.svelte.js";
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import type { MaybeElementGetter } from "../../internal/types.js";
|
||||
import { type ActiveElementOptions } from "../active-element/active-element.svelte.js";
|
||||
export interface IsFocusWithinOptions extends ActiveElementOptions {
|
||||
}
|
||||
/**
|
||||
* Tracks whether the focus is within a target element.
|
||||
* @see {@link https://runed.dev/docs/utilities/is-focus-within}
|
||||
*/
|
||||
export declare class IsFocusWithin {
|
||||
#private;
|
||||
constructor(node: MaybeElementGetter, options?: IsFocusWithinOptions);
|
||||
readonly current: boolean;
|
||||
}
|
||||
+20
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user