mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
refactor: Remove INavigable in favor of IFocusableNode. (#9037)
* refactor: Remove INavigable in favor of IFocusableNode. * chore: Fix JSDoc. * chore: Address review feedback.
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type {IFocusableNode} from './i_focusable_node.js';
|
||||
|
||||
/**
|
||||
* Represents a UI element which can be navigated to using the keyboard.
|
||||
*/
|
||||
export interface INavigable<T> extends IFocusableNode {
|
||||
/**
|
||||
* Returns the class of this instance.
|
||||
*
|
||||
* @returns This object's class.
|
||||
*/
|
||||
getClass(): new (...args: any) => T;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type {INavigable} from './i_navigable.js';
|
||||
import type {IFocusableNode} from './i_focusable_node.js';
|
||||
|
||||
/**
|
||||
* A set of rules that specify where keyboard navigation should proceed.
|
||||
@@ -16,7 +16,7 @@ export interface INavigationPolicy<T> {
|
||||
* @param current The element which the user is navigating into.
|
||||
* @returns The current element's first child, or null if it has none.
|
||||
*/
|
||||
getFirstChild(current: T): INavigable<any> | null;
|
||||
getFirstChild(current: T): IFocusableNode | null;
|
||||
|
||||
/**
|
||||
* Returns the parent element of the given element, if any.
|
||||
@@ -24,7 +24,7 @@ export interface INavigationPolicy<T> {
|
||||
* @param current The element which the user is navigating out of.
|
||||
* @returns The parent element of the current element, or null if it has none.
|
||||
*/
|
||||
getParent(current: T): INavigable<any> | null;
|
||||
getParent(current: T): IFocusableNode | null;
|
||||
|
||||
/**
|
||||
* Returns the peer element following the given element, if any.
|
||||
@@ -33,7 +33,7 @@ export interface INavigationPolicy<T> {
|
||||
* @returns The next peer element of the current element, or null if there is
|
||||
* none.
|
||||
*/
|
||||
getNextSibling(current: T): INavigable<any> | null;
|
||||
getNextSibling(current: T): IFocusableNode | null;
|
||||
|
||||
/**
|
||||
* Returns the peer element preceding the given element, if any.
|
||||
@@ -42,7 +42,7 @@ export interface INavigationPolicy<T> {
|
||||
* @returns The previous peer element of the current element, or null if
|
||||
* there is none.
|
||||
*/
|
||||
getPreviousSibling(current: T): INavigable<any> | null;
|
||||
getPreviousSibling(current: T): IFocusableNode | null;
|
||||
|
||||
/**
|
||||
* Returns whether or not the given instance should be reachable via keyboard
|
||||
@@ -57,4 +57,13 @@ export interface INavigationPolicy<T> {
|
||||
* @returns True if this element should be included in keyboard navigation.
|
||||
*/
|
||||
isNavigable(current: T): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether or not this navigation policy corresponds to the type of
|
||||
* the given object.
|
||||
*
|
||||
* @param current An instance to check whether this policy applies to.
|
||||
* @returns True if the given object is of a type handled by this policy.
|
||||
*/
|
||||
isApplicable(current: any): current is T;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user