blockly 12.0.0-beta.4 → 12.0.0-beta.6

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 (336) hide show
  1. package/blockly.min.js +715 -664
  2. package/blockly.mjs +11 -1
  3. package/blockly_compressed.js +679 -661
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks_compressed.js +3 -3
  6. package/blocks_compressed.js.map +1 -1
  7. package/core/block.d.ts +1 -16
  8. package/core/block_svg.d.ts +19 -31
  9. package/core/blockly.d.ts +15 -7
  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 +3 -2
  15. package/core/contextmenu_registry.d.ts +11 -9
  16. package/core/dialog.d.ts +36 -16
  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 +28 -30
  21. package/core/field_dropdown.d.ts +17 -3
  22. package/core/field_image.d.ts +0 -2
  23. package/core/field_input.d.ts +9 -0
  24. package/core/field_variable.d.ts +0 -2
  25. package/core/flyout_base.d.ts +25 -1
  26. package/core/flyout_button.d.ts +15 -13
  27. package/core/flyout_item.d.ts +3 -9
  28. package/core/flyout_navigator.d.ts +11 -0
  29. package/core/flyout_separator.d.ts +20 -1
  30. package/core/focus_manager.d.ts +86 -14
  31. package/core/icons/comment_icon.d.ts +3 -0
  32. package/core/icons/icon.d.ts +13 -0
  33. package/core/icons/mutator_icon.d.ts +3 -0
  34. package/core/icons/warning_icon.d.ts +3 -0
  35. package/core/interfaces/i_autohideable.d.ts +2 -0
  36. package/core/interfaces/i_bubble.d.ts +2 -1
  37. package/core/interfaces/i_flyout.d.ts +2 -1
  38. package/core/interfaces/i_focusable_node.d.ts +71 -8
  39. package/core/interfaces/i_focusable_tree.d.ts +67 -0
  40. package/core/interfaces/i_has_bubble.d.ts +13 -0
  41. package/core/interfaces/i_icon.d.ts +2 -1
  42. package/core/interfaces/i_navigation_policy.d.ts +63 -0
  43. package/core/interfaces/i_selectable.d.ts +7 -1
  44. package/core/interfaces/i_toolbox.d.ts +2 -1
  45. package/core/interfaces/i_toolbox_item.d.ts +2 -1
  46. package/core/keyboard_nav/block_navigation_policy.d.ts +59 -0
  47. package/core/keyboard_nav/connection_navigation_policy.d.ts +67 -0
  48. package/core/keyboard_nav/field_navigation_policy.d.ts +56 -0
  49. package/core/keyboard_nav/flyout_button_navigation_policy.d.ts +56 -0
  50. package/core/keyboard_nav/flyout_navigation_policy.d.ts +65 -0
  51. package/core/keyboard_nav/flyout_separator_navigation_policy.d.ts +33 -0
  52. package/core/keyboard_nav/line_cursor.d.ts +24 -185
  53. package/core/keyboard_nav/marker.d.ts +17 -29
  54. package/core/keyboard_nav/workspace_navigation_policy.d.ts +56 -0
  55. package/core/layer_manager.d.ts +3 -2
  56. package/core/marker_manager.d.ts +0 -26
  57. package/core/navigator.d.ts +65 -0
  58. package/core/rendered_connection.d.ts +24 -1
  59. package/core/renderers/common/block_rendering.d.ts +1 -2
  60. package/core/renderers/common/drawer.d.ts +1 -1
  61. package/core/renderers/common/i_path_object.d.ts +1 -25
  62. package/core/renderers/common/path_object.d.ts +1 -26
  63. package/core/renderers/common/renderer.d.ts +0 -11
  64. package/core/renderers/zelos/drawer.d.ts +1 -1
  65. package/core/renderers/zelos/renderer.d.ts +0 -11
  66. package/core/renderers/zelos/zelos.d.ts +1 -2
  67. package/core/shortcut_registry.d.ts +7 -2
  68. package/core/toast.d.ts +74 -0
  69. package/core/toolbox/toolbox.d.ts +25 -1
  70. package/core/toolbox/toolbox_item.d.ts +11 -0
  71. package/core/utils/aria.d.ts +5 -2
  72. package/core/utils/object.d.ts +3 -0
  73. package/core/variable_map.d.ts +11 -6
  74. package/core/variables.d.ts +3 -1
  75. package/core/workspace.d.ts +11 -11
  76. package/core/workspace_dragger.d.ts +5 -0
  77. package/core/workspace_svg.d.ts +99 -48
  78. package/index.mjs +11 -1
  79. package/msg/ab.js +33 -0
  80. package/msg/ab.mjs +33 -0
  81. package/msg/ace.js +33 -0
  82. package/msg/ace.mjs +33 -0
  83. package/msg/af.js +33 -0
  84. package/msg/af.mjs +33 -0
  85. package/msg/am.js +33 -0
  86. package/msg/am.mjs +33 -0
  87. package/msg/ar.js +33 -0
  88. package/msg/ar.mjs +33 -0
  89. package/msg/ast.js +33 -0
  90. package/msg/ast.mjs +33 -0
  91. package/msg/az.js +33 -0
  92. package/msg/az.mjs +33 -0
  93. package/msg/ba.js +33 -0
  94. package/msg/ba.mjs +33 -0
  95. package/msg/bcc.js +33 -0
  96. package/msg/bcc.mjs +33 -0
  97. package/msg/be-tarask.js +33 -0
  98. package/msg/be-tarask.mjs +33 -0
  99. package/msg/be.js +33 -0
  100. package/msg/be.mjs +33 -0
  101. package/msg/bg.js +33 -0
  102. package/msg/bg.mjs +33 -0
  103. package/msg/bn.js +33 -0
  104. package/msg/bn.mjs +33 -0
  105. package/msg/br.js +33 -0
  106. package/msg/br.mjs +33 -0
  107. package/msg/bs.js +33 -0
  108. package/msg/bs.mjs +33 -0
  109. package/msg/ca.js +33 -0
  110. package/msg/ca.mjs +33 -0
  111. package/msg/cdo.js +33 -0
  112. package/msg/cdo.mjs +33 -0
  113. package/msg/ce.js +33 -0
  114. package/msg/ce.mjs +33 -0
  115. package/msg/cs.js +33 -0
  116. package/msg/cs.mjs +33 -0
  117. package/msg/da.js +33 -0
  118. package/msg/da.mjs +33 -0
  119. package/msg/de.js +33 -0
  120. package/msg/de.mjs +33 -0
  121. package/msg/diq.js +33 -0
  122. package/msg/diq.mjs +33 -0
  123. package/msg/dtp.js +33 -0
  124. package/msg/dtp.mjs +33 -0
  125. package/msg/dty.js +33 -0
  126. package/msg/dty.mjs +33 -0
  127. package/msg/ee.js +33 -0
  128. package/msg/ee.mjs +33 -0
  129. package/msg/el.js +33 -0
  130. package/msg/el.mjs +33 -0
  131. package/msg/en-gb.js +33 -0
  132. package/msg/en-gb.mjs +33 -0
  133. package/msg/en.js +33 -0
  134. package/msg/en.mjs +33 -0
  135. package/msg/eo.js +33 -0
  136. package/msg/eo.mjs +33 -0
  137. package/msg/es.js +33 -0
  138. package/msg/es.mjs +33 -0
  139. package/msg/et.js +33 -0
  140. package/msg/et.mjs +33 -0
  141. package/msg/eu.js +33 -0
  142. package/msg/eu.mjs +33 -0
  143. package/msg/fa.js +33 -0
  144. package/msg/fa.mjs +33 -0
  145. package/msg/fi.js +33 -0
  146. package/msg/fi.mjs +33 -0
  147. package/msg/fo.js +33 -0
  148. package/msg/fo.mjs +33 -0
  149. package/msg/fr.js +33 -0
  150. package/msg/fr.mjs +33 -0
  151. package/msg/frr.js +33 -0
  152. package/msg/frr.mjs +33 -0
  153. package/msg/gl.js +33 -0
  154. package/msg/gl.mjs +33 -0
  155. package/msg/gn.js +33 -0
  156. package/msg/gn.mjs +33 -0
  157. package/msg/gor.js +33 -0
  158. package/msg/gor.mjs +33 -0
  159. package/msg/ha.js +33 -0
  160. package/msg/ha.mjs +33 -0
  161. package/msg/hak.js +33 -0
  162. package/msg/hak.mjs +33 -0
  163. package/msg/he.js +33 -0
  164. package/msg/he.mjs +33 -0
  165. package/msg/hi.js +33 -0
  166. package/msg/hi.mjs +33 -0
  167. package/msg/hr.js +33 -0
  168. package/msg/hr.mjs +33 -0
  169. package/msg/hrx.js +33 -0
  170. package/msg/hrx.mjs +33 -0
  171. package/msg/hsb.js +33 -0
  172. package/msg/hsb.mjs +33 -0
  173. package/msg/hu.js +33 -0
  174. package/msg/hu.mjs +33 -0
  175. package/msg/hy.js +33 -0
  176. package/msg/hy.mjs +33 -0
  177. package/msg/ia.js +33 -0
  178. package/msg/ia.mjs +33 -0
  179. package/msg/id.js +33 -0
  180. package/msg/id.mjs +33 -0
  181. package/msg/ig.js +33 -0
  182. package/msg/ig.mjs +33 -0
  183. package/msg/inh.js +33 -0
  184. package/msg/inh.mjs +33 -0
  185. package/msg/is.js +33 -0
  186. package/msg/is.mjs +33 -0
  187. package/msg/it.js +33 -0
  188. package/msg/it.mjs +33 -0
  189. package/msg/ja.js +33 -0
  190. package/msg/ja.mjs +33 -0
  191. package/msg/ka.js +33 -0
  192. package/msg/ka.mjs +33 -0
  193. package/msg/kab.js +33 -0
  194. package/msg/kab.mjs +33 -0
  195. package/msg/kbd-cyrl.js +33 -0
  196. package/msg/kbd-cyrl.mjs +33 -0
  197. package/msg/km.js +33 -0
  198. package/msg/km.mjs +33 -0
  199. package/msg/kn.js +33 -0
  200. package/msg/kn.mjs +33 -0
  201. package/msg/ko.js +33 -0
  202. package/msg/ko.mjs +33 -0
  203. package/msg/ksh.js +33 -0
  204. package/msg/ksh.mjs +33 -0
  205. package/msg/ku-latn.js +33 -0
  206. package/msg/ku-latn.mjs +33 -0
  207. package/msg/ky.js +33 -0
  208. package/msg/ky.mjs +33 -0
  209. package/msg/la.js +33 -0
  210. package/msg/la.mjs +33 -0
  211. package/msg/lb.js +33 -0
  212. package/msg/lb.mjs +33 -0
  213. package/msg/lki.js +33 -0
  214. package/msg/lki.mjs +33 -0
  215. package/msg/lo.js +33 -0
  216. package/msg/lo.mjs +33 -0
  217. package/msg/lrc.js +33 -0
  218. package/msg/lrc.mjs +33 -0
  219. package/msg/lt.js +33 -0
  220. package/msg/lt.mjs +33 -0
  221. package/msg/lv.js +33 -0
  222. package/msg/lv.mjs +33 -0
  223. package/msg/mg.js +33 -0
  224. package/msg/mg.mjs +33 -0
  225. package/msg/mk.js +33 -0
  226. package/msg/mk.mjs +33 -0
  227. package/msg/ml.js +33 -0
  228. package/msg/ml.mjs +33 -0
  229. package/msg/mnw.js +33 -0
  230. package/msg/mnw.mjs +33 -0
  231. package/msg/ms.js +33 -0
  232. package/msg/ms.mjs +33 -0
  233. package/msg/my.js +33 -0
  234. package/msg/my.mjs +33 -0
  235. package/msg/mzn.js +33 -0
  236. package/msg/mzn.mjs +33 -0
  237. package/msg/nb.js +33 -0
  238. package/msg/nb.mjs +33 -0
  239. package/msg/ne.js +33 -0
  240. package/msg/ne.mjs +33 -0
  241. package/msg/nl.js +33 -0
  242. package/msg/nl.mjs +33 -0
  243. package/msg/oc.js +33 -0
  244. package/msg/oc.mjs +33 -0
  245. package/msg/olo.js +33 -0
  246. package/msg/olo.mjs +33 -0
  247. package/msg/pa.js +33 -0
  248. package/msg/pa.mjs +33 -0
  249. package/msg/pl.js +33 -0
  250. package/msg/pl.mjs +33 -0
  251. package/msg/pms.js +33 -0
  252. package/msg/pms.mjs +33 -0
  253. package/msg/ps.js +33 -0
  254. package/msg/ps.mjs +33 -0
  255. package/msg/pt-br.js +33 -0
  256. package/msg/pt-br.mjs +33 -0
  257. package/msg/pt.js +33 -0
  258. package/msg/pt.mjs +33 -0
  259. package/msg/ro.js +33 -0
  260. package/msg/ro.mjs +33 -0
  261. package/msg/ru.js +33 -0
  262. package/msg/ru.mjs +33 -0
  263. package/msg/sc.js +33 -0
  264. package/msg/sc.mjs +33 -0
  265. package/msg/sco.js +33 -0
  266. package/msg/sco.mjs +33 -0
  267. package/msg/sd.js +33 -0
  268. package/msg/sd.mjs +33 -0
  269. package/msg/shn.js +33 -0
  270. package/msg/shn.mjs +33 -0
  271. package/msg/si.js +33 -0
  272. package/msg/si.mjs +33 -0
  273. package/msg/sk.js +33 -0
  274. package/msg/sk.mjs +33 -0
  275. package/msg/skr-arab.js +33 -0
  276. package/msg/skr-arab.mjs +33 -0
  277. package/msg/sl.js +33 -0
  278. package/msg/sl.mjs +33 -0
  279. package/msg/smn.js +33 -0
  280. package/msg/smn.mjs +33 -0
  281. package/msg/sq.js +33 -0
  282. package/msg/sq.mjs +33 -0
  283. package/msg/sr-latn.js +33 -0
  284. package/msg/sr-latn.mjs +33 -0
  285. package/msg/sr.js +33 -0
  286. package/msg/sr.mjs +33 -0
  287. package/msg/sv.js +33 -0
  288. package/msg/sv.mjs +33 -0
  289. package/msg/sw.js +33 -0
  290. package/msg/sw.mjs +33 -0
  291. package/msg/ta.js +33 -0
  292. package/msg/ta.mjs +33 -0
  293. package/msg/tcy.js +33 -0
  294. package/msg/tcy.mjs +33 -0
  295. package/msg/tdd.js +33 -0
  296. package/msg/tdd.mjs +33 -0
  297. package/msg/te.js +33 -0
  298. package/msg/te.mjs +33 -0
  299. package/msg/th.js +33 -0
  300. package/msg/th.mjs +33 -0
  301. package/msg/ti.js +33 -0
  302. package/msg/ti.mjs +33 -0
  303. package/msg/tl.js +33 -0
  304. package/msg/tl.mjs +33 -0
  305. package/msg/tlh.js +33 -0
  306. package/msg/tlh.mjs +33 -0
  307. package/msg/tr.js +33 -0
  308. package/msg/tr.mjs +33 -0
  309. package/msg/ug-arab.js +33 -0
  310. package/msg/ug-arab.mjs +33 -0
  311. package/msg/uk.js +33 -0
  312. package/msg/uk.mjs +33 -0
  313. package/msg/ur.js +33 -0
  314. package/msg/ur.mjs +33 -0
  315. package/msg/uz.js +33 -0
  316. package/msg/uz.mjs +33 -0
  317. package/msg/vi.js +33 -0
  318. package/msg/vi.mjs +33 -0
  319. package/msg/xmf.js +33 -0
  320. package/msg/xmf.mjs +33 -0
  321. package/msg/yo.js +33 -0
  322. package/msg/yo.mjs +33 -0
  323. package/msg/zgh.js +33 -0
  324. package/msg/zgh.mjs +33 -0
  325. package/msg/zh-hans.js +33 -0
  326. package/msg/zh-hans.mjs +33 -0
  327. package/msg/zh-hant.js +33 -0
  328. package/msg/zh-hant.mjs +33 -0
  329. package/package.json +4 -4
  330. package/core/events/events_marker_move.d.ts +0 -69
  331. package/core/interfaces/i_ast_node_location.d.ts +0 -11
  332. package/core/interfaces/i_ast_node_location_svg.d.ts +0 -24
  333. package/core/interfaces/i_ast_node_location_with_block.d.ts +0 -19
  334. package/core/keyboard_nav/ast_node.d.ts +0 -297
  335. package/core/renderers/common/marker_svg.d.ts +0 -256
  336. package/core/renderers/zelos/marker_svg.d.ts +0 -49
@@ -17,21 +17,84 @@ 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).
25
- *
26
- * It's expected the return element will not change for the lifetime of the
27
- * node.
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).
27
+ *
28
+ * The returned element must be visible if the node is ever focused via
29
+ * FocusManager.focusNode() or FocusManager.focusTree(). It's allowed for an
30
+ * element to be hidden until onNodeFocus() is called, or become hidden with a
31
+ * call to onNodeBlur().
32
+ *
33
+ * It's expected the actual returned element will not change for the lifetime
34
+ * of the node (that is, its properties can change but a new element should
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.
28
39
  */
29
40
  getFocusableElement(): HTMLElement | SVGElement;
30
41
  /**
31
42
  * Returns the closest parent tree of this node (in cases where a tree has
32
43
  * distinct trees underneath it), which represents the tree to which this node
33
44
  * belongs.
45
+ *
46
+ * @returns The node's IFocusableTree.
34
47
  */
35
48
  getFocusableTree(): IFocusableTree;
49
+ /**
50
+ * Called when this node receives active focus.
51
+ *
52
+ * Note that it's fine for implementations to change visibility modifiers, but
53
+ * they should avoid the following:
54
+ * - Creating or removing DOM elements (including via the renderer or drawer).
55
+ * - Affecting focus via DOM focus() calls or the FocusManager.
56
+ */
57
+ onNodeFocus(): void;
58
+ /**
59
+ * Called when this node loses active focus. It may still have passive focus.
60
+ *
61
+ * This has the same implementation restrictions as onNodeFocus().
62
+ */
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;
36
91
  }
92
+ /**
93
+ * Determines whether the provided object fulfills the contract of
94
+ * IFocusableNode.
95
+ *
96
+ * @param object The object to test.
97
+ * @returns Whether the provided object can be used as an IFocusableNode.
98
+ */
99
+ export declare function isFocusableNode(object: any | null): object is IFocusableNode;
37
100
  //# sourceMappingURL=i_focusable_node.d.ts.map
@@ -34,6 +34,35 @@ export interface IFocusableTree {
34
34
  * currently have a focused node.
35
35
  */
36
36
  getRootFocusableNode(): IFocusableNode;
37
+ /**
38
+ * Returns the IFocusableNode of this tree that should receive active focus
39
+ * when the tree itself has focus returned to it.
40
+ *
41
+ * There are some very important notes to consider about a tree's focus
42
+ * lifecycle when implementing a version of this method that doesn't return
43
+ * null:
44
+ * 1. A null previousNode does not guarantee first-time focus state as nodes
45
+ * can be deleted.
46
+ * 2. This method is only used when the tree itself is focused, either through
47
+ * tab navigation or via FocusManager.focusTree(). In many cases, the
48
+ * previously focused node will be directly focused instead which will
49
+ * bypass this method.
50
+ * 3. The default behavior (i.e. returning null here) involves either
51
+ * restoring the previous node (previousNode) or focusing the tree's root.
52
+ * 4. The provided node may sometimes no longer be valid, such as in the case
53
+ * an attempt is made to focus a node that has been recently removed from
54
+ * its parent tree. Implementations can check for the validity of the node
55
+ * in order to specialize the node to which focus should fall back.
56
+ *
57
+ * This method is largely intended to provide tree implementations with the
58
+ * means of specifying a better default node than their root.
59
+ *
60
+ * @param previousNode The node that previously held passive focus for this
61
+ * tree, or null if the tree hasn't yet been focused.
62
+ * @returns The IFocusableNode that should now receive focus, or null if
63
+ * default behavior should be used, instead.
64
+ */
65
+ getRestoredFocusableNode(previousNode: IFocusableNode | null): IFocusableNode | null;
37
66
  /**
38
67
  * Returns all directly nested trees under this tree.
39
68
  *
@@ -54,5 +83,43 @@ export interface IFocusableTree {
54
83
  * @param id The ID of the node's focusable HTMLElement or SVGElement.
55
84
  */
56
85
  lookUpFocusableNode(id: string): IFocusableNode | null;
86
+ /**
87
+ * Called when a node of this tree has received active focus.
88
+ *
89
+ * Note that a null previousTree does not necessarily indicate that this is
90
+ * the first time Blockly is receiving focus. In fact, few assumptions can be
91
+ * made about previous focus state as a previous null tree simply indicates
92
+ * that Blockly did not hold active focus prior to this tree becoming focused
93
+ * (which can happen due to focus exiting the Blockly injection div, or for
94
+ * other cases like ephemeral focus).
95
+ *
96
+ * See IFocusableNode.onNodeFocus() as implementations have the same
97
+ * restrictions as with that method.
98
+ *
99
+ * @param node The node receiving active focus.
100
+ * @param previousTree The previous tree that held active focus, or null if
101
+ * none.
102
+ */
103
+ onTreeFocus(node: IFocusableNode, previousTree: IFocusableTree | null): void;
104
+ /**
105
+ * Called when the previously actively focused node of this tree is now
106
+ * passively focused and there is no other active node of this tree taking its
107
+ * place.
108
+ *
109
+ * This has the same implementation restrictions and considerations as
110
+ * onTreeFocus().
111
+ *
112
+ * @param nextTree The next tree receiving active focus, or null if none (such
113
+ * as in the case that Blockly is entirely losing DOM focus).
114
+ */
115
+ onTreeBlur(nextTree: IFocusableTree | null): void;
57
116
  }
117
+ /**
118
+ * Determines whether the provided object fulfills the contract of
119
+ * IFocusableTree.
120
+ *
121
+ * @param object The object to test.
122
+ * @returns Whether the provided object can be used as an IFocusableTree.
123
+ */
124
+ export declare function isFocusableTree(object: any | null): object is IFocusableTree;
58
125
  //# sourceMappingURL=i_focusable_tree.d.ts.map
@@ -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`.
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { IFocusableNode } from './i_focusable_node.js';
7
+ /**
8
+ * A set of rules that specify where keyboard navigation should proceed.
9
+ */
10
+ export interface INavigationPolicy<T> {
11
+ /**
12
+ * Returns the first child element of the given element, if any.
13
+ *
14
+ * @param current The element which the user is navigating into.
15
+ * @returns The current element's first child, or null if it has none.
16
+ */
17
+ getFirstChild(current: T): IFocusableNode | null;
18
+ /**
19
+ * Returns the parent element of the given element, if any.
20
+ *
21
+ * @param current The element which the user is navigating out of.
22
+ * @returns The parent element of the current element, or null if it has none.
23
+ */
24
+ getParent(current: T): IFocusableNode | null;
25
+ /**
26
+ * Returns the peer element following the given element, if any.
27
+ *
28
+ * @param current The element which the user is navigating past.
29
+ * @returns The next peer element of the current element, or null if there is
30
+ * none.
31
+ */
32
+ getNextSibling(current: T): IFocusableNode | null;
33
+ /**
34
+ * Returns the peer element preceding the given element, if any.
35
+ *
36
+ * @param current The element which the user is navigating past.
37
+ * @returns The previous peer element of the current element, or null if
38
+ * there is none.
39
+ */
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;
62
+ }
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. */
@@ -6,12 +6,13 @@
6
6
  import type { ToolboxInfo } from '../utils/toolbox.js';
7
7
  import type { WorkspaceSvg } from '../workspace_svg.js';
8
8
  import type { IFlyout } from './i_flyout.js';
9
+ import type { IFocusableTree } from './i_focusable_tree.js';
9
10
  import type { IRegistrable } from './i_registrable.js';
10
11
  import type { IToolboxItem } from './i_toolbox_item.js';
11
12
  /**
12
13
  * Interface for a toolbox.
13
14
  */
14
- export interface IToolbox extends IRegistrable {
15
+ export interface IToolbox extends IRegistrable, IFocusableTree {
15
16
  /** Initializes the toolbox. */
16
17
  init(): void;
17
18
  /**
@@ -3,10 +3,11 @@
3
3
  * Copyright 2020 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import type { IFocusableNode } from './i_focusable_node.js';
6
7
  /**
7
8
  * Interface for an item in the toolbox.
8
9
  */
9
- export interface IToolboxItem {
10
+ export interface IToolboxItem extends IFocusableNode {
10
11
  /**
11
12
  * Initializes the toolbox item.
12
13
  * This includes creating the DOM and updating the state of any items based
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { BlockSvg } from '../block_svg.js';
7
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Set of rules controlling keyboard navigation from a block.
11
+ */
12
+ export declare class BlockNavigationPolicy implements INavigationPolicy<BlockSvg> {
13
+ /**
14
+ * Returns the first child of the given block.
15
+ *
16
+ * @param current The block to return the first child of.
17
+ * @returns The first field or input of the given block, if any.
18
+ */
19
+ getFirstChild(current: BlockSvg): IFocusableNode | null;
20
+ /**
21
+ * Returns the parent of the given block.
22
+ *
23
+ * @param current The block to return the parent of.
24
+ * @returns The top block of the given block's stack, or the connection to
25
+ * which it is attached.
26
+ */
27
+ getParent(current: BlockSvg): IFocusableNode | null;
28
+ /**
29
+ * Returns the next peer node of the given block.
30
+ *
31
+ * @param current The block to find the following element of.
32
+ * @returns The first block of the next stack if the given block is a terminal
33
+ * block, or its next connection.
34
+ */
35
+ getNextSibling(current: BlockSvg): IFocusableNode | null;
36
+ /**
37
+ * Returns the previous peer node of the given block.
38
+ *
39
+ * @param current The block to find the preceding element of.
40
+ * @returns The block's previous/output connection, or the last
41
+ * connection/block of the previous block stack if it is a root block.
42
+ */
43
+ getPreviousSibling(current: BlockSvg): IFocusableNode | null;
44
+ /**
45
+ * Returns whether or not the given block can be navigated to.
46
+ *
47
+ * @param current The instance to check for navigability.
48
+ * @returns True if the given block can be focused.
49
+ */
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;
58
+ }
59
+ //# sourceMappingURL=block_navigation_policy.d.ts.map
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { BlockSvg } from '../block_svg.js';
7
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ import { RenderedConnection } from '../rendered_connection.js';
10
+ /**
11
+ * Set of rules controlling keyboard navigation from a connection.
12
+ */
13
+ export declare class ConnectionNavigationPolicy implements INavigationPolicy<RenderedConnection> {
14
+ /**
15
+ * Returns the first child of the given connection.
16
+ *
17
+ * @param current The connection to return the first child of.
18
+ * @returns The connection's first child element, or null if not none.
19
+ */
20
+ getFirstChild(current: RenderedConnection): IFocusableNode | null;
21
+ /**
22
+ * Returns the parent of the given connection.
23
+ *
24
+ * @param current The connection to return the parent of.
25
+ * @returns The given connection's parent connection or block.
26
+ */
27
+ getParent(current: RenderedConnection): IFocusableNode | null;
28
+ /**
29
+ * Returns the next element following the given connection.
30
+ *
31
+ * @param current The connection to navigate from.
32
+ * @returns The field, input connection or block following this connection.
33
+ */
34
+ getNextSibling(current: RenderedConnection): IFocusableNode | null;
35
+ /**
36
+ * Returns the element preceding the given connection.
37
+ *
38
+ * @param current The connection to navigate from.
39
+ * @returns The field, input connection or block preceding this connection.
40
+ */
41
+ getPreviousSibling(current: RenderedConnection): IFocusableNode | null;
42
+ /**
43
+ * Gets the parent connection on a block.
44
+ * This is either an output connection, previous connection or undefined.
45
+ * If both connections exist return the one that is actually connected
46
+ * to another block.
47
+ *
48
+ * @param block The block to find the parent connection on.
49
+ * @returns The connection connecting to the parent of the block.
50
+ */
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;
66
+ }
67
+ //# sourceMappingURL=connection_navigation_policy.d.ts.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Field } from '../field.js';
7
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Set of rules controlling keyboard navigation from a field.
11
+ */
12
+ export declare class FieldNavigationPolicy implements INavigationPolicy<Field<any>> {
13
+ /**
14
+ * Returns null since fields do not have children.
15
+ *
16
+ * @param _current The field to navigate from.
17
+ * @returns Null.
18
+ */
19
+ getFirstChild(_current: Field<any>): IFocusableNode | null;
20
+ /**
21
+ * Returns the parent block of the given field.
22
+ *
23
+ * @param current The field to navigate from.
24
+ * @returns The given field's parent block.
25
+ */
26
+ getParent(current: Field<any>): IFocusableNode | null;
27
+ /**
28
+ * Returns the next field or input following the given field.
29
+ *
30
+ * @param current The field to navigate from.
31
+ * @returns The next field or input in the given field's block.
32
+ */
33
+ getNextSibling(current: Field<any>): IFocusableNode | null;
34
+ /**
35
+ * Returns the field or input preceding the given field.
36
+ *
37
+ * @param current The field to navigate from.
38
+ * @returns The preceding field or input in the given field's block.
39
+ */
40
+ getPreviousSibling(current: Field<any>): IFocusableNode | null;
41
+ /**
42
+ * Returns whether or not the given field can be navigated to.
43
+ *
44
+ * @param current The instance to check for navigability.
45
+ * @returns True if the given field can be focused and navigated to.
46
+ */
47
+ isNavigable(current: Field<any>): boolean;
48
+ /**
49
+ * Returns whether the given object can be navigated from by this policy.
50
+ *
51
+ * @param current The object to check if this policy applies to.
52
+ * @returns True if the object is a Field.
53
+ */
54
+ isApplicable(current: any): current is Field;
55
+ }
56
+ //# sourceMappingURL=field_navigation_policy.d.ts.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { FlyoutButton } from '../flyout_button.js';
7
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Set of rules controlling keyboard navigation from a flyout button.
11
+ */
12
+ export declare class FlyoutButtonNavigationPolicy implements INavigationPolicy<FlyoutButton> {
13
+ /**
14
+ * Returns null since flyout buttons have no children.
15
+ *
16
+ * @param _current The FlyoutButton instance to navigate from.
17
+ * @returns Null.
18
+ */
19
+ getFirstChild(_current: FlyoutButton): IFocusableNode | null;
20
+ /**
21
+ * Returns the parent workspace of the given flyout button.
22
+ *
23
+ * @param current The FlyoutButton instance to navigate from.
24
+ * @returns The given flyout button's parent workspace.
25
+ */
26
+ getParent(current: FlyoutButton): IFocusableNode | null;
27
+ /**
28
+ * Returns null since inter-item navigation is done by FlyoutNavigationPolicy.
29
+ *
30
+ * @param _current The FlyoutButton instance to navigate from.
31
+ * @returns Null.
32
+ */
33
+ getNextSibling(_current: FlyoutButton): IFocusableNode | null;
34
+ /**
35
+ * Returns null since inter-item navigation is done by FlyoutNavigationPolicy.
36
+ *
37
+ * @param _current The FlyoutButton instance to navigate from.
38
+ * @returns Null.
39
+ */
40
+ getPreviousSibling(_current: FlyoutButton): IFocusableNode | null;
41
+ /**
42
+ * Returns whether or not the given flyout button can be navigated to.
43
+ *
44
+ * @param current The instance to check for navigability.
45
+ * @returns True if the given flyout button can be focused.
46
+ */
47
+ isNavigable(current: FlyoutButton): boolean;
48
+ /**
49
+ * Returns whether the given object can be navigated from by this policy.
50
+ *
51
+ * @param current The object to check if this policy applies to.
52
+ * @returns True if the object is a FlyoutButton.
53
+ */
54
+ isApplicable(current: any): current is FlyoutButton;
55
+ }
56
+ //# sourceMappingURL=flyout_button_navigation_policy.d.ts.map
@@ -0,0 +1,65 @@
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 type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Generic navigation policy that navigates between items in the flyout.
11
+ */
12
+ export declare class FlyoutNavigationPolicy<T> implements INavigationPolicy<T> {
13
+ private policy;
14
+ private flyout;
15
+ /**
16
+ * Creates a new FlyoutNavigationPolicy instance.
17
+ *
18
+ * @param policy The policy to defer to for parents/children.
19
+ * @param flyout The flyout this policy will control navigation in.
20
+ */
21
+ constructor(policy: INavigationPolicy<T>, flyout: IFlyout);
22
+ /**
23
+ * Returns null to prevent navigating into flyout items.
24
+ *
25
+ * @param _current The flyout item to navigate from.
26
+ * @returns Null to prevent navigating into flyout items.
27
+ */
28
+ getFirstChild(_current: T): IFocusableNode | null;
29
+ /**
30
+ * Returns the parent of the given flyout item.
31
+ *
32
+ * @param current The flyout item to navigate from.
33
+ * @returns The parent of the given flyout item.
34
+ */
35
+ getParent(current: T): IFocusableNode | null;
36
+ /**
37
+ * Returns the next item in the flyout relative to the given item.
38
+ *
39
+ * @param current The flyout item to navigate from.
40
+ * @returns The flyout item following the given one.
41
+ */
42
+ getNextSibling(current: T): IFocusableNode | null;
43
+ /**
44
+ * Returns the previous item in the flyout relative to the given item.
45
+ *
46
+ * @param current The flyout item to navigate from.
47
+ * @returns The flyout item preceding the given one.
48
+ */
49
+ getPreviousSibling(current: T): IFocusableNode | null;
50
+ /**
51
+ * Returns whether or not the given flyout item can be navigated to.
52
+ *
53
+ * @param current The instance to check for navigability.
54
+ * @returns True if the given flyout item can be focused.
55
+ */
56
+ isNavigable(current: T): boolean;
57
+ /**
58
+ * Returns whether the given object can be navigated from by this policy.
59
+ *
60
+ * @param current The object to check if this policy applies to.
61
+ * @returns True if the object is a BlockSvg.
62
+ */
63
+ isApplicable(current: any): current is T;
64
+ }
65
+ //# sourceMappingURL=flyout_navigation_policy.d.ts.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { FlyoutSeparator } from '../flyout_separator.js';
7
+ import type { IFocusableNode } from '../interfaces/i_focusable_node.js';
8
+ import type { INavigationPolicy } from '../interfaces/i_navigation_policy.js';
9
+ /**
10
+ * Set of rules controlling keyboard navigation from a flyout separator.
11
+ * This is a no-op placeholder, since flyout separators can't be navigated to.
12
+ */
13
+ export declare class FlyoutSeparatorNavigationPolicy implements INavigationPolicy<FlyoutSeparator> {
14
+ getFirstChild(_current: FlyoutSeparator): IFocusableNode | null;
15
+ getParent(_current: FlyoutSeparator): IFocusableNode | null;
16
+ getNextSibling(_current: FlyoutSeparator): IFocusableNode | null;
17
+ getPreviousSibling(_current: FlyoutSeparator): IFocusableNode | null;
18
+ /**
19
+ * Returns whether or not the given flyout separator can be navigated to.
20
+ *
21
+ * @param _current The instance to check for navigability.
22
+ * @returns False.
23
+ */
24
+ isNavigable(_current: FlyoutSeparator): boolean;
25
+ /**
26
+ * Returns whether the given object can be navigated from by this policy.
27
+ *
28
+ * @param current The object to check if this policy applies to.
29
+ * @returns True if the object is a FlyoutSeparator.
30
+ */
31
+ isApplicable(current: any): current is FlyoutSeparator;
32
+ }
33
+ //# sourceMappingURL=flyout_separator_navigation_policy.d.ts.map