blockly 12.0.0-beta.5 → 12.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/blockly.min.js +396 -403
  2. package/blockly.mjs +1 -1
  3. package/blockly_compressed.js +395 -402
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +1 -1
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +1 -16
  8. package/core/block_svg.d.ts +3 -31
  9. package/core/blockly.d.ts +4 -8
  10. package/core/bubbles/bubble.d.ts +22 -3
  11. package/core/bubbles/textinput_bubble.d.ts +3 -5
  12. package/core/comments/rendered_workspace_comment.d.ts +11 -0
  13. package/core/common.d.ts +19 -7
  14. package/core/connection.d.ts +1 -2
  15. package/core/contextmenu_registry.d.ts +1 -1
  16. package/core/dropdowndiv.d.ts +3 -1
  17. package/core/events/events.d.ts +0 -2
  18. package/core/events/predicates.d.ts +0 -3
  19. package/core/events/utils.d.ts +1 -5
  20. package/core/field.d.ts +20 -20
  21. package/core/field_checkbox.d.ts +0 -9
  22. package/core/field_dropdown.d.ts +7 -10
  23. package/core/field_image.d.ts +0 -11
  24. package/core/field_input.d.ts +16 -1
  25. package/core/field_label.d.ts +0 -9
  26. package/core/field_number.d.ts +0 -9
  27. package/core/field_textinput.d.ts +0 -9
  28. package/core/field_variable.d.ts +0 -2
  29. package/core/flyout_base.d.ts +3 -1
  30. package/core/flyout_button.d.ts +3 -24
  31. package/core/flyout_item.d.ts +3 -3
  32. package/core/flyout_navigator.d.ts +11 -0
  33. package/core/flyout_separator.d.ts +13 -11
  34. package/core/focus_manager.d.ts +9 -5
  35. package/core/icons/comment_icon.d.ts +3 -0
  36. package/core/icons/icon.d.ts +13 -0
  37. package/core/icons/mutator_icon.d.ts +3 -0
  38. package/core/icons/warning_icon.d.ts +3 -0
  39. package/core/interfaces/i_bubble.d.ts +2 -1
  40. package/core/interfaces/i_focusable_node.d.ts +39 -5
  41. package/core/interfaces/i_has_bubble.d.ts +13 -0
  42. package/core/interfaces/i_icon.d.ts +2 -1
  43. package/core/interfaces/i_navigation_policy.d.ts +26 -5
  44. package/core/interfaces/i_selectable.d.ts +7 -1
  45. package/core/keyboard_nav/block_navigation_policy.d.ts +17 -14
  46. package/core/keyboard_nav/connection_navigation_policy.d.ts +20 -6
  47. package/core/keyboard_nav/field_navigation_policy.d.ts +20 -6
  48. package/core/keyboard_nav/flyout_button_navigation_policy.d.ts +20 -6
  49. package/core/keyboard_nav/flyout_navigation_policy.d.ts +19 -5
  50. package/core/keyboard_nav/flyout_separator_navigation_policy.d.ts +20 -6
  51. package/core/keyboard_nav/line_cursor.d.ts +14 -104
  52. package/core/keyboard_nav/marker.d.ts +7 -10
  53. package/core/keyboard_nav/workspace_navigation_policy.d.ts +20 -6
  54. package/core/layer_manager.d.ts +3 -2
  55. package/core/navigator.d.ts +12 -12
  56. package/core/rendered_connection.d.ts +3 -14
  57. package/core/toolbox/toolbox.d.ts +2 -0
  58. package/core/toolbox/toolbox_item.d.ts +2 -0
  59. package/core/utils/object.d.ts +3 -0
  60. package/core/variable_map.d.ts +7 -2
  61. package/core/widgetdiv.d.ts +6 -1
  62. package/core/workspace.d.ts +1 -2
  63. package/core/workspace_dragger.d.ts +5 -0
  64. package/core/workspace_svg.d.ts +10 -15
  65. package/index.mjs +1 -1
  66. package/package.json +1 -1
  67. package/core/events/events_marker_move.d.ts +0 -69
  68. package/core/interfaces/i_ast_node_location.d.ts +0 -11
  69. package/core/interfaces/i_ast_node_location_svg.d.ts +0 -12
  70. package/core/interfaces/i_ast_node_location_with_block.d.ts +0 -19
  71. package/core/interfaces/i_navigable.d.ts +0 -30
  72. package/core/keyboard_nav/ast_node.d.ts +0 -185
@@ -48,15 +48,6 @@ export declare class FieldTextInput extends FieldInput<string> {
48
48
  * @internal
49
49
  */
50
50
  static fromJson(options: FieldTextInputFromJsonConfig): FieldTextInput;
51
- /**
52
- * Returns this field's class.
53
- *
54
- * Used by keyboard navigation to look up the rules for navigating from this
55
- * field.
56
- *
57
- * @returns This field's class.
58
- */
59
- getClass(): typeof FieldTextInput;
60
51
  }
61
52
  /**
62
53
  * Config options for the text input field.
@@ -15,7 +15,6 @@ import { FieldDropdown, FieldDropdownValidator, MenuGenerator, MenuOption } from
15
15
  import { IVariableModel, IVariableState } from './interfaces/i_variable_model.js';
16
16
  import type { Menu } from './menu.js';
17
17
  import type { MenuItem } from './menuitem.js';
18
- import { Size } from './utils/size.js';
19
18
  /**
20
19
  * Class for a variable's dropdown field.
21
20
  */
@@ -29,7 +28,6 @@ export declare class FieldVariable extends FieldDropdown {
29
28
  * dropdown.
30
29
  */
31
30
  variableTypes: string[] | null;
32
- protected size_: Size;
33
31
  /** The variable model associated with this field. */
34
32
  private variable;
35
33
  /**
@@ -15,7 +15,7 @@ import { IAutoHideable } from './interfaces/i_autohideable.js';
15
15
  import type { IFlyout } from './interfaces/i_flyout.js';
16
16
  import type { IFlyoutInflater } from './interfaces/i_flyout_inflater.js';
17
17
  import { IFocusableNode } from './interfaces/i_focusable_node.js';
18
- import { IFocusableTree } from './interfaces/i_focusable_tree.js';
18
+ import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
19
19
  import type { Options } from './options.js';
20
20
  import * as blocks from './serialization/blocks.js';
21
21
  import { Coordinate } from './utils/coordinate.js';
@@ -409,6 +409,8 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
409
409
  onNodeFocus(): void;
410
410
  /** See IFocusableNode.onNodeBlur. */
411
411
  onNodeBlur(): void;
412
+ /** See IFocusableNode.canBeFocused. */
413
+ canBeFocused(): boolean;
412
414
  /** See IFocusableTree.getRootFocusableNode. */
413
415
  getRootFocusableNode(): IFocusableNode;
414
416
  /** See IFocusableTree.getRestoredFocusableNode. */
@@ -3,16 +3,9 @@
3
3
  * Copyright 2016 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- /**
7
- * Class for a button in the flyout.
8
- *
9
- * @class
10
- */
11
- import type { IASTNodeLocationSvg } from './blockly.js';
12
6
  import type { IBoundedElement } from './interfaces/i_bounded_element.js';
13
7
  import type { IFocusableNode } from './interfaces/i_focusable_node.js';
14
8
  import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
15
- import type { INavigable } from './interfaces/i_navigable.js';
16
9
  import type { IRenderedElement } from './interfaces/i_rendered_element.js';
17
10
  import { Coordinate } from './utils/coordinate.js';
18
11
  import { Rect } from './utils/rect.js';
@@ -21,7 +14,7 @@ import type { WorkspaceSvg } from './workspace_svg.js';
21
14
  /**
22
15
  * Class for a button or label in the flyout.
23
16
  */
24
- export declare class FlyoutButton implements IASTNodeLocationSvg, IBoundedElement, IRenderedElement, IFocusableNode, INavigable<FlyoutButton> {
17
+ export declare class FlyoutButton implements IBoundedElement, IRenderedElement, IFocusableNode {
25
18
  private readonly workspace;
26
19
  private readonly targetWorkspace;
27
20
  private readonly isFlyoutLabel;
@@ -140,21 +133,7 @@ export declare class FlyoutButton implements IASTNodeLocationSvg, IBoundedElemen
140
133
  onNodeFocus(): void;
141
134
  /** See IFocusableNode.onNodeBlur. */
142
135
  onNodeBlur(): void;
143
- /**
144
- * Returns whether or not this button is accessible through keyboard
145
- * navigation.
146
- *
147
- * @returns True if this button is keyboard accessible, otherwise false.
148
- */
149
- isNavigable(): boolean;
150
- /**
151
- * Returns this button's class.
152
- *
153
- * Used by keyboard navigation to look up the rules for navigating from this
154
- * button.
155
- *
156
- * @returns This button's class.
157
- */
158
- getClass(): typeof FlyoutButton;
136
+ /** See IFocusableNode.canBeFocused. */
137
+ canBeFocused(): boolean;
159
138
  }
160
139
  //# sourceMappingURL=flyout_button.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import type { IBoundedElement } from './interfaces/i_bounded_element.js';
2
- import type { INavigable } from './interfaces/i_navigable.js';
2
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
3
3
  /**
4
4
  * Representation of an item displayed in a flyout.
5
5
  */
@@ -13,11 +13,11 @@ export declare class FlyoutItem {
13
13
  * @param type The type of element. Should correspond to the type of the
14
14
  * flyout inflater that created this object.
15
15
  */
16
- constructor(element: IBoundedElement & INavigable<any>, type: string);
16
+ constructor(element: IBoundedElement & IFocusableNode, type: string);
17
17
  /**
18
18
  * Returns the element displayed in the flyout.
19
19
  */
20
- getElement(): IBoundedElement & INavigable<any>;
20
+ getElement(): IBoundedElement & IFocusableNode;
21
21
  /**
22
22
  * Returns the type of flyout element this item represents.
23
23
  */
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IFlyout } from './interfaces/i_flyout.js';
7
+ import { Navigator } from './navigator.js';
8
+ export declare class FlyoutNavigator extends Navigator {
9
+ constructor(flyout: IFlyout);
10
+ }
11
+ //# sourceMappingURL=flyout_navigator.d.ts.map
@@ -4,12 +4,13 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { IBoundedElement } from './interfaces/i_bounded_element.js';
7
- import type { INavigable } from './interfaces/i_navigable.js';
7
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
8
+ import type { IFocusableTree } from './interfaces/i_focusable_tree.js';
8
9
  import { Rect } from './utils/rect.js';
9
10
  /**
10
11
  * Representation of a gap between elements in a flyout.
11
12
  */
12
- export declare class FlyoutSeparator implements IBoundedElement, INavigable<FlyoutSeparator> {
13
+ export declare class FlyoutSeparator implements IBoundedElement, IFocusableNode {
13
14
  private gap;
14
15
  private axis;
15
16
  private x;
@@ -42,15 +43,16 @@ export declare class FlyoutSeparator implements IBoundedElement, INavigable<Flyo
42
43
  * @returns False.
43
44
  */
44
45
  isNavigable(): boolean;
45
- /**
46
- * Returns this separator's class.
47
- *
48
- * Used by keyboard navigation to look up the rules for navigating from this
49
- * separator.
50
- *
51
- * @returns This separator's class.
52
- */
53
- getClass(): typeof FlyoutSeparator;
46
+ /** See IFocusableNode.getFocusableElement. */
47
+ getFocusableElement(): HTMLElement | SVGElement;
48
+ /** See IFocusableNode.getFocusableTree. */
49
+ getFocusableTree(): IFocusableTree;
50
+ /** See IFocusableNode.onNodeFocus. */
51
+ onNodeFocus(): void;
52
+ /** See IFocusableNode.onNodeBlur. */
53
+ onNodeBlur(): void;
54
+ /** See IFocusableNode.canBeFocused. */
55
+ canBeFocused(): boolean;
54
56
  }
55
57
  /**
56
58
  * Representation of an axis along which a separator occupies space.
@@ -128,6 +128,10 @@ export declare class FocusManager {
128
128
  * Any previously focused node will be updated to be passively highlighted (if
129
129
  * it's in a different focusable tree) or blurred (if it's in the same one).
130
130
  *
131
+ * **Important**: If the provided node is not able to be focused (e.g. its
132
+ * canBeFocused() method returns false), it will be ignored and any existing
133
+ * focus state will remain unchanged.
134
+ *
131
135
  * @param focusableNode The node that should receive active focus.
132
136
  */
133
137
  focusNode(focusableNode: IFocusableNode): void;
@@ -171,9 +175,9 @@ export declare class FocusManager {
171
175
  */
172
176
  private defocusCurrentFocusedNode;
173
177
  /**
174
- * Marks the specified node as actively focused, also calling related lifecycle
175
- * callback methods for both the node and its parent tree. This ensures that
176
- * the node is properly styled to indicate its active focus.
178
+ * Marks the specified node as actively focused, also calling related
179
+ * lifecycle callback methods for both the node and its parent tree. This
180
+ * ensures that the node is properly styled to indicate its active focus.
177
181
  *
178
182
  * This does not change the manager's currently tracked node, nor does it
179
183
  * change any other nodes.
@@ -221,8 +225,8 @@ export declare class FocusManager {
221
225
  /**
222
226
  * Returns the page-global FocusManager.
223
227
  *
224
- * The returned instance is guaranteed to not change across function calls, but
225
- * may change across page loads.
228
+ * The returned instance is guaranteed to not change across function calls,
229
+ * but may change across page loads.
226
230
  */
227
231
  static getFocusManager(): FocusManager;
228
232
  }
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { Block } from '../block.js';
7
+ import type { IBubble } from '../interfaces/i_bubble.js';
7
8
  import type { IHasBubble } from '../interfaces/i_has_bubble.js';
8
9
  import type { ISerializable } from '../interfaces/i_serializable.js';
9
10
  import { Coordinate } from '../utils.js';
@@ -92,6 +93,8 @@ export declare class CommentIcon extends Icon implements IHasBubble, ISerializab
92
93
  onBubbleLocationChange(): void;
93
94
  bubbleIsVisible(): boolean;
94
95
  setBubbleVisible(visible: boolean): Promise<void>;
96
+ /** See IHasBubble.getBubble. */
97
+ getBubble(): IBubble | null;
95
98
  /**
96
99
  * Shows the editable text bubble for this comment, and adds change listeners
97
100
  * to update the state of this icon in response to changes in the bubble.
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { Block } from '../block.js';
7
+ import type { IFocusableTree } from '../interfaces/i_focusable_tree.js';
7
8
  import type { IIcon } from '../interfaces/i_icon.js';
8
9
  import * as tooltip from '../tooltip.js';
9
10
  import { Coordinate } from '../utils/coordinate.js';
@@ -28,6 +29,8 @@ export declare abstract class Icon implements IIcon {
28
29
  protected svgRoot: SVGGElement | null;
29
30
  /** The tooltip for this icon. */
30
31
  protected tooltip: tooltip.TipInfo;
32
+ /** The unique ID of this icon. */
33
+ private id;
31
34
  constructor(sourceBlock: Block);
32
35
  getType(): IconType<IIcon>;
33
36
  initView(pointerdownListener: (e: PointerEvent) => void): void;
@@ -59,5 +62,15 @@ export declare abstract class Icon implements IIcon {
59
62
  * @returns Whether the icon should be clickable while the block is in a flyout.
60
63
  */
61
64
  isClickableInFlyout(autoClosingFlyout: boolean): boolean;
65
+ /** See IFocusableNode.getFocusableElement. */
66
+ getFocusableElement(): HTMLElement | SVGElement;
67
+ /** See IFocusableNode.getFocusableTree. */
68
+ getFocusableTree(): IFocusableTree;
69
+ /** See IFocusableNode.onNodeFocus. */
70
+ onNodeFocus(): void;
71
+ /** See IFocusableNode.onNodeBlur. */
72
+ onNodeBlur(): void;
73
+ /** See IFocusableNode.canBeFocused. */
74
+ canBeFocused(): boolean;
62
75
  }
63
76
  //# sourceMappingURL=icon.d.ts.map
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { BlockSvg } from '../block_svg.js';
7
7
  import type { Abstract } from '../events/events_abstract.js';
8
+ import type { IBubble } from '../interfaces/i_bubble.js';
8
9
  import type { IHasBubble } from '../interfaces/i_has_bubble.js';
9
10
  import { Coordinate } from '../utils/coordinate.js';
10
11
  import { Size } from '../utils/size.js';
@@ -54,6 +55,8 @@ export declare class MutatorIcon extends Icon implements IHasBubble {
54
55
  isClickableInFlyout(): boolean;
55
56
  bubbleIsVisible(): boolean;
56
57
  setBubbleVisible(visible: boolean): Promise<void>;
58
+ /** See IHasBubble.getBubble. */
59
+ getBubble(): IBubble | null;
57
60
  /** @returns the configuration the mini workspace should have. */
58
61
  private getMiniWorkspaceConfig;
59
62
  /**
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { BlockSvg } from '../block_svg.js';
7
+ import type { IBubble } from '../interfaces/i_bubble.js';
7
8
  import type { IHasBubble } from '../interfaces/i_has_bubble.js';
8
9
  import { Size } from '../utils.js';
9
10
  import { Coordinate } from '../utils/coordinate.js';
@@ -60,6 +61,8 @@ export declare class WarningIcon extends Icon implements IHasBubble {
60
61
  isClickableInFlyout(): boolean;
61
62
  bubbleIsVisible(): boolean;
62
63
  setBubbleVisible(visible: boolean): Promise<void>;
64
+ /** See IHasBubble.getBubble. */
65
+ getBubble(): IBubble | null;
63
66
  /**
64
67
  * @returns the location the bubble should be anchored to.
65
68
  * I.E. the middle of this icon.
@@ -6,10 +6,11 @@
6
6
  import type { Coordinate } from '../utils/coordinate.js';
7
7
  import type { IContextMenu } from './i_contextmenu.js';
8
8
  import type { IDraggable } from './i_draggable.js';
9
+ import { IFocusableNode } from './i_focusable_node.js';
9
10
  /**
10
11
  * A bubble interface.
11
12
  */
12
- export interface IBubble extends IDraggable, IContextMenu {
13
+ export interface IBubble extends IDraggable, IContextMenu, IFocusableNode {
13
14
  /**
14
15
  * Return the coordinates of the top-left corner of this bubble's body
15
16
  * relative to the drawing surface's origin (0,0), in workspace units.
@@ -17,11 +17,13 @@ export interface IFocusableNode {
17
17
  * - blocklyActiveFocus
18
18
  * - blocklyPassiveFocus
19
19
  *
20
- * The returned element must also have a valid ID specified, and unique to the
21
- * element relative to its nearest IFocusableTree parent. It must also have a
22
- * negative tabindex (since the focus manager itself will manage its tab index
23
- * and a tab index must be present in order for the element to be focusable in
24
- * the DOM).
20
+ * The returned element must also have a valid ID specified, and unique across
21
+ * the entire page. Failing to have a properly unique ID could result in
22
+ * trying to focus one node (such as via a mouse click) leading to another
23
+ * node with the same ID actually becoming focused by FocusManager. The
24
+ * returned element must also have a negative tabindex (since the focus
25
+ * manager itself will manage its tab index and a tab index must be present in
26
+ * order for the element to be focusable in the DOM).
25
27
  *
26
28
  * The returned element must be visible if the node is ever focused via
27
29
  * FocusManager.focusNode() or FocusManager.focusTree(). It's allowed for an
@@ -31,12 +33,17 @@ export interface IFocusableNode {
31
33
  * It's expected the actual returned element will not change for the lifetime
32
34
  * of the node (that is, its properties can change but a new element should
33
35
  * never be returned).
36
+ *
37
+ * @returns The HTMLElement or SVGElement which can both receive focus and be
38
+ * visually represented as actively or passively focused for this node.
34
39
  */
35
40
  getFocusableElement(): HTMLElement | SVGElement;
36
41
  /**
37
42
  * Returns the closest parent tree of this node (in cases where a tree has
38
43
  * distinct trees underneath it), which represents the tree to which this node
39
44
  * belongs.
45
+ *
46
+ * @returns The node's IFocusableTree.
40
47
  */
41
48
  getFocusableTree(): IFocusableTree;
42
49
  /**
@@ -54,6 +61,33 @@ export interface IFocusableNode {
54
61
  * This has the same implementation restrictions as onNodeFocus().
55
62
  */
56
63
  onNodeBlur(): void;
64
+ /**
65
+ * Indicates whether this node allows focus. If this returns false then none
66
+ * of the other IFocusableNode methods will be called.
67
+ *
68
+ * Note that special care must be taken if implementations of this function
69
+ * dynamically change their return value value over the lifetime of the node
70
+ * as certain environment conditions could affect the focusability of this
71
+ * node's DOM element (such as whether the element has a positive or zero
72
+ * tabindex). Also, changing from a true to a false value while the node holds
73
+ * focus will not immediately change the current focus of the node nor
74
+ * FocusManager's internal state, and thus may result in some of the node's
75
+ * functions being called later on when defocused (since it was previously
76
+ * considered focusable at the time of being focused).
77
+ *
78
+ * Implementations should generally always return true here unless there are
79
+ * circumstances under which this node should be skipped for focus
80
+ * considerations. Examples may include being disabled, read-only, a purely
81
+ * visual decoration, or a node with no visual representation that must
82
+ * implement this interface (e.g. due to a parent interface extending it).
83
+ * Keep in mind accessibility best practices when determining whether a node
84
+ * should be focusable since even disabled and read-only elements are still
85
+ * often relevant to providing organizational context to users (particularly
86
+ * when using a screen reader).
87
+ *
88
+ * @returns Whether this node can be focused by FocusManager.
89
+ */
90
+ canBeFocused(): boolean;
57
91
  }
58
92
  /**
59
93
  * Determines whether the provided object fulfills the contract of
@@ -3,11 +3,24 @@
3
3
  * Copyright 2023 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import type { IBubble } from './i_bubble';
6
7
  export interface IHasBubble {
7
8
  /** @returns True if the bubble is currently open, false otherwise. */
8
9
  bubbleIsVisible(): boolean;
9
10
  /** Sets whether the bubble is open or not. */
10
11
  setBubbleVisible(visible: boolean): Promise<void>;
12
+ /**
13
+ * Returns the current IBubble that implementations are managing, or null if
14
+ * there isn't one.
15
+ *
16
+ * Note that this cannot be expected to return null if bubbleIsVisible()
17
+ * returns false, i.e., the nullability of the returned bubble does not
18
+ * necessarily imply visibility.
19
+ *
20
+ * @returns The current IBubble maintained by implementations, or null if
21
+ * there is not one.
22
+ */
23
+ getBubble(): IBubble | null;
11
24
  }
12
25
  /** Type guard that checks whether the given object is a IHasBubble. */
13
26
  export declare function hasBubble(obj: any): obj is IHasBubble;
@@ -6,7 +6,8 @@
6
6
  import type { IconType } from '../icons/icon_types.js';
7
7
  import type { Coordinate } from '../utils/coordinate.js';
8
8
  import type { Size } from '../utils/size.js';
9
- export interface IIcon {
9
+ import { IFocusableNode } from './i_focusable_node.js';
10
+ export interface IIcon extends IFocusableNode {
10
11
  /**
11
12
  * @returns the IconType representing the type of the icon. This value should
12
13
  * also be used to register the icon via `Blockly.icons.registry.register`.
@@ -3,7 +3,7 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { INavigable } from './i_navigable.js';
6
+ import type { IFocusableNode } from './i_focusable_node.js';
7
7
  /**
8
8
  * A set of rules that specify where keyboard navigation should proceed.
9
9
  */
@@ -14,14 +14,14 @@ export interface INavigationPolicy<T> {
14
14
  * @param current The element which the user is navigating into.
15
15
  * @returns The current element's first child, or null if it has none.
16
16
  */
17
- getFirstChild(current: T): INavigable<any> | null;
17
+ getFirstChild(current: T): IFocusableNode | null;
18
18
  /**
19
19
  * Returns the parent element of the given element, if any.
20
20
  *
21
21
  * @param current The element which the user is navigating out of.
22
22
  * @returns The parent element of the current element, or null if it has none.
23
23
  */
24
- getParent(current: T): INavigable<any> | null;
24
+ getParent(current: T): IFocusableNode | null;
25
25
  /**
26
26
  * Returns the peer element following the given element, if any.
27
27
  *
@@ -29,7 +29,7 @@ export interface INavigationPolicy<T> {
29
29
  * @returns The next peer element of the current element, or null if there is
30
30
  * none.
31
31
  */
32
- getNextSibling(current: T): INavigable<any> | null;
32
+ getNextSibling(current: T): IFocusableNode | null;
33
33
  /**
34
34
  * Returns the peer element preceding the given element, if any.
35
35
  *
@@ -37,6 +37,27 @@ export interface INavigationPolicy<T> {
37
37
  * @returns The previous peer element of the current element, or null if
38
38
  * there is none.
39
39
  */
40
- getPreviousSibling(current: T): INavigable<any> | null;
40
+ getPreviousSibling(current: T): IFocusableNode | null;
41
+ /**
42
+ * Returns whether or not the given instance should be reachable via keyboard
43
+ * navigation.
44
+ *
45
+ * Implementors should generally return true, unless there are circumstances
46
+ * under which this item should be skipped while using keyboard navigation.
47
+ * Common examples might include being disabled, invalid, readonly, or purely
48
+ * a visual decoration. For example, while Fields are navigable, non-editable
49
+ * fields return false, since they cannot be interacted with when focused.
50
+ *
51
+ * @returns True if this element should be included in keyboard navigation.
52
+ */
53
+ isNavigable(current: T): boolean;
54
+ /**
55
+ * Returns whether or not this navigation policy corresponds to the type of
56
+ * the given object.
57
+ *
58
+ * @param current An instance to check whether this policy applies to.
59
+ * @returns True if the given object is of a type handled by this policy.
60
+ */
61
+ isApplicable(current: any): current is T;
41
62
  }
42
63
  //# sourceMappingURL=i_navigation_policy.d.ts.map
@@ -4,10 +4,16 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { Workspace } from '../workspace.js';
7
+ import { IFocusableNode } from './i_focusable_node.js';
7
8
  /**
8
9
  * The interface for an object that is selectable.
10
+ *
11
+ * Implementations are generally expected to use their implementations of
12
+ * onNodeFocus() and onNodeBlur() to call setSelected() with themselves and
13
+ * null, respectively, in order to ensure that selections are correctly updated
14
+ * and the selection change event is fired.
9
15
  */
10
- export interface ISelectable {
16
+ export interface ISelectable extends IFocusableNode {
11
17
  id: string;
12
18
  workspace: Workspace;
13
19
  /** Select this. Highlight it visually. */
@@ -3,10 +3,9 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import type { BlockSvg } from '../block_svg.js';
7
- import type { INavigable } from '../interfaces/i_navigable.js';
6
+ import { BlockSvg } from '../block_svg.js';
7
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
8
  import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
- import type { RenderedConnection } from '../rendered_connection.js';
10
9
  /**
11
10
  * Set of rules controlling keyboard navigation from a block.
12
11
  */
@@ -17,7 +16,7 @@ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg
17
16
  * @param current The block to return the first child of.
18
17
  * @returns The first field or input of the given block, if any.
19
18
  */
20
- getFirstChild(current: BlockSvg): INavigable<unknown> | null;
19
+ getFirstChild(current: BlockSvg): IFocusableNode | null;
21
20
  /**
22
21
  * Returns the parent of the given block.
23
22
  *
@@ -25,7 +24,7 @@ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg
25
24
  * @returns The top block of the given block's stack, or the connection to
26
25
  * which it is attached.
27
26
  */
28
- getParent(current: BlockSvg): INavigable<unknown> | null;
27
+ getParent(current: BlockSvg): IFocusableNode | null;
29
28
  /**
30
29
  * Returns the next peer node of the given block.
31
30
  *
@@ -33,7 +32,7 @@ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg
33
32
  * @returns The first block of the next stack if the given block is a terminal
34
33
  * block, or its next connection.
35
34
  */
36
- getNextSibling(current: BlockSvg): INavigable<unknown> | null;
35
+ getNextSibling(current: BlockSvg): IFocusableNode | null;
37
36
  /**
38
37
  * Returns the previous peer node of the given block.
39
38
  *
@@ -41,16 +40,20 @@ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg
41
40
  * @returns The block's previous/output connection, or the last
42
41
  * connection/block of the previous block stack if it is a root block.
43
42
  */
44
- getPreviousSibling(current: BlockSvg): INavigable<unknown> | null;
43
+ getPreviousSibling(current: BlockSvg): IFocusableNode | null;
45
44
  /**
46
- * Gets the parent connection on a block.
47
- * This is either an output connection, previous connection or undefined.
48
- * If both connections exist return the one that is actually connected
49
- * to another block.
45
+ * Returns whether or not the given block can be navigated to.
50
46
  *
51
- * @param block The block to find the parent connection on.
52
- * @returns The connection connecting to the parent of the block.
47
+ * @param current The instance to check for navigability.
48
+ * @returns True if the given block can be focused.
53
49
  */
54
- protected getParentConnection(block: BlockSvg): RenderedConnection;
50
+ isNavigable(current: BlockSvg): boolean;
51
+ /**
52
+ * Returns whether the given object can be navigated from by this policy.
53
+ *
54
+ * @param current The object to check if this policy applies to.
55
+ * @returns True if the object is a BlockSvg.
56
+ */
57
+ isApplicable(current: any): current is BlockSvg;
55
58
  }
56
59
  //# sourceMappingURL=block_navigation_policy.d.ts.map
@@ -4,9 +4,9 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { BlockSvg } from '../block_svg.js';
7
- import type { INavigable } from '../interfaces/i_navigable.js';
7
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
8
  import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
- import type { RenderedConnection } from '../rendered_connection.js';
9
+ import { RenderedConnection } from '../rendered_connection.js';
10
10
  /**
11
11
  * Set of rules controlling keyboard navigation from a connection.
12
12
  */
@@ -17,28 +17,28 @@ export declare class ConnectionNavigationPolicy implements INavigationPolicy<Ren
17
17
  * @param current The connection to return the first child of.
18
18
  * @returns The connection's first child element, or null if not none.
19
19
  */
20
- getFirstChild(current: RenderedConnection): INavigable<unknown> | null;
20
+ getFirstChild(current: RenderedConnection): IFocusableNode | null;
21
21
  /**
22
22
  * Returns the parent of the given connection.
23
23
  *
24
24
  * @param current The connection to return the parent of.
25
25
  * @returns The given connection's parent connection or block.
26
26
  */
27
- getParent(current: RenderedConnection): INavigable<unknown> | null;
27
+ getParent(current: RenderedConnection): IFocusableNode | null;
28
28
  /**
29
29
  * Returns the next element following the given connection.
30
30
  *
31
31
  * @param current The connection to navigate from.
32
32
  * @returns The field, input connection or block following this connection.
33
33
  */
34
- getNextSibling(current: RenderedConnection): INavigable<unknown> | null;
34
+ getNextSibling(current: RenderedConnection): IFocusableNode | null;
35
35
  /**
36
36
  * Returns the element preceding the given connection.
37
37
  *
38
38
  * @param current The connection to navigate from.
39
39
  * @returns The field, input connection or block preceding this connection.
40
40
  */
41
- getPreviousSibling(current: RenderedConnection): INavigable<unknown> | null;
41
+ getPreviousSibling(current: RenderedConnection): IFocusableNode | null;
42
42
  /**
43
43
  * Gets the parent connection on a block.
44
44
  * This is either an output connection, previous connection or undefined.
@@ -49,5 +49,19 @@ export declare class ConnectionNavigationPolicy implements INavigationPolicy<Ren
49
49
  * @returns The connection connecting to the parent of the block.
50
50
  */
51
51
  protected getParentConnection(block: BlockSvg): RenderedConnection;
52
+ /**
53
+ * Returns whether or not the given connection can be navigated to.
54
+ *
55
+ * @param current The instance to check for navigability.
56
+ * @returns True if the given connection can be focused.
57
+ */
58
+ isNavigable(current: RenderedConnection): boolean;
59
+ /**
60
+ * Returns whether the given object can be navigated from by this policy.
61
+ *
62
+ * @param current The object to check if this policy applies to.
63
+ * @returns True if the object is a RenderedConnection.
64
+ */
65
+ isApplicable(current: any): current is RenderedConnection;
52
66
  }
53
67
  //# sourceMappingURL=connection_navigation_policy.d.ts.map