Revert "chore: Remove unused isFocusable*() functions."

This reverts commit 404c20eeaf.
This commit is contained in:
Ben Henning
2025-04-21 21:09:26 +00:00
parent c91fed3fdb
commit 4e8bb9850f
2 changed files with 36 additions and 0 deletions

View File

@@ -60,3 +60,20 @@ export interface IFocusableNode {
*/
onNodeBlur(): void;
}
/**
* Determines whether the provided object fulfills the contract of
* IFocusableNode.
*
* @param object The object to test.
* @returns Whether the provided object can be used as an IFocusableNode.
*/
export function isFocusableNode(object: any | null): object is IFocusableNode {
return (
object &&
'getFocusableElement' in object &&
'getFocusableTree' in object &&
'onNodeFocus' in object &&
'onNodeBlur' in object
);
}

View File

@@ -119,3 +119,22 @@ export interface IFocusableTree {
*/
onTreeBlur(nextTree: IFocusableTree | null): void;
}
/**
* Determines whether the provided object fulfills the contract of
* IFocusableTree.
*
* @param object The object to test.
* @returns Whether the provided object can be used as an IFocusableTree.
*/
export function isFocusableTree(object: any | null): object is IFocusableTree {
return (
object &&
'getRootFocusableNode' in object &&
'getRestoredFocusableNode' in object &&
'getNestedTrees' in object &&
'lookUpFocusableNode' in object &&
'onTreeFocus' in object &&
'onTreeBlur' in object
);
}