blockly 13.0.0-beta.1 → 13.0.0-beta.3

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 (298) hide show
  1. package/blockly.min.js +1290 -1233
  2. package/blockly_compressed.js +1131 -1103
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +71 -71
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/block.d.ts +18 -0
  7. package/core/block_aria_composer.d.ts +1 -1
  8. package/core/bubbles/bubble.d.ts +39 -0
  9. package/core/bubbles/textinput_bubble.d.ts +5 -0
  10. package/core/field_checkbox.d.ts +27 -0
  11. package/core/field_dropdown.d.ts +51 -1
  12. package/core/field_image.d.ts +24 -0
  13. package/core/field_input.d.ts +1 -1
  14. package/core/field_number.d.ts +10 -0
  15. package/core/field_textinput.d.ts +10 -0
  16. package/core/field_variable.d.ts +9 -0
  17. package/core/flyout_base.d.ts +10 -0
  18. package/core/icons/comment_icon.d.ts +8 -0
  19. package/core/icons/icon.d.ts +14 -0
  20. package/core/icons/mutator_icon.d.ts +8 -0
  21. package/core/icons/warning_icon.d.ts +8 -0
  22. package/core/inputs/input.d.ts +28 -0
  23. package/core/interfaces/i_flyout_inflater.d.ts +9 -0
  24. package/core/interfaces/i_json_block_definition.d.ts +1 -0
  25. package/core/menu.d.ts +3 -0
  26. package/core/menuitem.d.ts +8 -1
  27. package/core/shortcut_items.d.ts +6 -1
  28. package/core/tooltip.d.ts +10 -0
  29. package/core/trashcan.d.ts +23 -38
  30. package/core/utils/aria.d.ts +7 -1
  31. package/core/workspace.d.ts +5 -1
  32. package/core/workspace_svg.d.ts +8 -0
  33. package/core/zoom_controls.d.ts +43 -50
  34. package/dart_compressed.js +62 -62
  35. package/dart_compressed.js.map +1 -1
  36. package/javascript_compressed.js +55 -55
  37. package/javascript_compressed.js.map +1 -1
  38. package/lua_compressed.js +50 -50
  39. package/lua_compressed.js.map +1 -1
  40. package/media/drop.mp3 +0 -0
  41. package/msg/ab.js +32 -3
  42. package/msg/ab.mjs +30 -1
  43. package/msg/ace.js +33 -4
  44. package/msg/ace.mjs +30 -1
  45. package/msg/af.js +32 -3
  46. package/msg/af.mjs +30 -1
  47. package/msg/am.js +33 -4
  48. package/msg/am.mjs +30 -1
  49. package/msg/ar.js +55 -26
  50. package/msg/ar.mjs +30 -1
  51. package/msg/ast.js +33 -4
  52. package/msg/ast.mjs +30 -1
  53. package/msg/az.js +33 -4
  54. package/msg/az.mjs +30 -1
  55. package/msg/ba.js +32 -3
  56. package/msg/ba.mjs +30 -1
  57. package/msg/bcc.js +32 -3
  58. package/msg/bcc.mjs +30 -1
  59. package/msg/be-tarask.js +66 -37
  60. package/msg/be-tarask.mjs +30 -1
  61. package/msg/be.js +33 -4
  62. package/msg/be.mjs +30 -1
  63. package/msg/bg.js +32 -3
  64. package/msg/bg.mjs +30 -1
  65. package/msg/bn.js +33 -4
  66. package/msg/bn.mjs +30 -1
  67. package/msg/br.js +33 -4
  68. package/msg/br.mjs +30 -1
  69. package/msg/bs.js +32 -3
  70. package/msg/bs.mjs +30 -1
  71. package/msg/ca.js +32 -3
  72. package/msg/ca.mjs +30 -1
  73. package/msg/ce.js +32 -3
  74. package/msg/ce.mjs +30 -1
  75. package/msg/cs.js +40 -11
  76. package/msg/cs.mjs +30 -1
  77. package/msg/da.js +56 -27
  78. package/msg/da.mjs +30 -1
  79. package/msg/de.js +32 -3
  80. package/msg/de.mjs +30 -1
  81. package/msg/diq.js +34 -5
  82. package/msg/diq.mjs +30 -1
  83. package/msg/dtp.js +32 -3
  84. package/msg/dtp.mjs +30 -1
  85. package/msg/dty.js +32 -3
  86. package/msg/dty.mjs +30 -1
  87. package/msg/ee.js +32 -3
  88. package/msg/ee.mjs +30 -1
  89. package/msg/el.js +63 -34
  90. package/msg/el.mjs +30 -1
  91. package/msg/en-gb.js +32 -3
  92. package/msg/en-gb.mjs +30 -1
  93. package/msg/en.js +33 -4
  94. package/msg/en.mjs +30 -1
  95. package/msg/eo.js +32 -3
  96. package/msg/eo.mjs +30 -1
  97. package/msg/es.js +42 -13
  98. package/msg/es.mjs +30 -1
  99. package/msg/et.js +32 -3
  100. package/msg/et.mjs +30 -1
  101. package/msg/eu.js +32 -3
  102. package/msg/eu.mjs +30 -1
  103. package/msg/fa.js +33 -4
  104. package/msg/fa.mjs +30 -1
  105. package/msg/fi.js +51 -22
  106. package/msg/fi.mjs +30 -1
  107. package/msg/fo.js +32 -3
  108. package/msg/fo.mjs +30 -1
  109. package/msg/fr.js +55 -26
  110. package/msg/fr.mjs +30 -1
  111. package/msg/frr.js +33 -4
  112. package/msg/frr.mjs +30 -1
  113. package/msg/ga.js +559 -0
  114. package/msg/{cdo.mjs → ga.mjs} +32 -3
  115. package/msg/gl.js +55 -26
  116. package/msg/gl.mjs +30 -1
  117. package/msg/gn.js +33 -4
  118. package/msg/gn.mjs +30 -1
  119. package/msg/gor.js +32 -3
  120. package/msg/gor.mjs +30 -1
  121. package/msg/ha.js +32 -3
  122. package/msg/ha.mjs +30 -1
  123. package/msg/hak.js +33 -4
  124. package/msg/hak.mjs +30 -1
  125. package/msg/he.js +82 -53
  126. package/msg/he.mjs +30 -1
  127. package/msg/hi.js +32 -3
  128. package/msg/hi.mjs +30 -1
  129. package/msg/hr.js +32 -3
  130. package/msg/hr.mjs +30 -1
  131. package/msg/hrx.js +32 -3
  132. package/msg/hrx.mjs +30 -1
  133. package/msg/hsb.js +32 -3
  134. package/msg/hsb.mjs +30 -1
  135. package/msg/hu.js +34 -5
  136. package/msg/hu.mjs +30 -1
  137. package/msg/hy.js +32 -3
  138. package/msg/hy.mjs +30 -1
  139. package/msg/ia.js +55 -26
  140. package/msg/ia.mjs +30 -1
  141. package/msg/id.js +262 -233
  142. package/msg/id.mjs +30 -1
  143. package/msg/ig.js +40 -11
  144. package/msg/ig.mjs +30 -1
  145. package/msg/inh.js +32 -3
  146. package/msg/inh.mjs +30 -1
  147. package/msg/is.js +32 -3
  148. package/msg/is.mjs +30 -1
  149. package/msg/it.js +58 -29
  150. package/msg/it.mjs +30 -1
  151. package/msg/ja.js +55 -26
  152. package/msg/ja.mjs +30 -1
  153. package/msg/ka.js +34 -5
  154. package/msg/ka.mjs +30 -1
  155. package/msg/kab.js +41 -12
  156. package/msg/kab.mjs +30 -1
  157. package/msg/kbd-cyrl.js +33 -4
  158. package/msg/kbd-cyrl.mjs +30 -1
  159. package/msg/km.js +32 -3
  160. package/msg/km.mjs +30 -1
  161. package/msg/kn.js +32 -3
  162. package/msg/kn.mjs +30 -1
  163. package/msg/ko.js +57 -28
  164. package/msg/ko.mjs +30 -1
  165. package/msg/krc.js +559 -0
  166. package/msg/krc.mjs +540 -0
  167. package/msg/ksh.js +33 -4
  168. package/msg/ksh.mjs +30 -1
  169. package/msg/ku-latn.js +33 -4
  170. package/msg/ku-latn.mjs +30 -1
  171. package/msg/ky.js +34 -5
  172. package/msg/ky.mjs +30 -1
  173. package/msg/la.js +33 -4
  174. package/msg/la.mjs +30 -1
  175. package/msg/lb.js +43 -14
  176. package/msg/lb.mjs +30 -1
  177. package/msg/lki.js +32 -3
  178. package/msg/lki.mjs +30 -1
  179. package/msg/lo.js +32 -3
  180. package/msg/lo.mjs +30 -1
  181. package/msg/lrc.js +32 -3
  182. package/msg/lrc.mjs +30 -1
  183. package/msg/lt.js +33 -4
  184. package/msg/lt.mjs +30 -1
  185. package/msg/lv.js +43 -14
  186. package/msg/lv.mjs +30 -1
  187. package/msg/mg.js +32 -3
  188. package/msg/mg.mjs +30 -1
  189. package/msg/mk.js +32 -3
  190. package/msg/mk.mjs +30 -1
  191. package/msg/ml.js +32 -3
  192. package/msg/ml.mjs +30 -1
  193. package/msg/mnw.js +32 -3
  194. package/msg/mnw.mjs +30 -1
  195. package/msg/ms.js +41 -12
  196. package/msg/ms.mjs +30 -1
  197. package/msg/my.js +32 -3
  198. package/msg/my.mjs +30 -1
  199. package/msg/mzn.js +33 -4
  200. package/msg/mzn.mjs +30 -1
  201. package/msg/nb.js +32 -3
  202. package/msg/nb.mjs +30 -1
  203. package/msg/ne.js +41 -12
  204. package/msg/ne.mjs +30 -1
  205. package/msg/nl.js +55 -26
  206. package/msg/nl.mjs +30 -1
  207. package/msg/oc.js +32 -3
  208. package/msg/oc.mjs +30 -1
  209. package/msg/olo.js +33 -4
  210. package/msg/olo.mjs +30 -1
  211. package/msg/pa.js +41 -12
  212. package/msg/pa.mjs +30 -1
  213. package/msg/pl.js +55 -26
  214. package/msg/pl.mjs +30 -1
  215. package/msg/pms.js +55 -26
  216. package/msg/pms.mjs +30 -1
  217. package/msg/ps.js +50 -21
  218. package/msg/ps.mjs +30 -1
  219. package/msg/pt-br.js +55 -26
  220. package/msg/pt-br.mjs +30 -1
  221. package/msg/pt.js +55 -26
  222. package/msg/pt.mjs +30 -1
  223. package/msg/ro.js +64 -35
  224. package/msg/ro.mjs +30 -1
  225. package/msg/ru.js +55 -26
  226. package/msg/ru.mjs +30 -1
  227. package/msg/sc.js +32 -3
  228. package/msg/sc.mjs +30 -1
  229. package/msg/sco.js +33 -4
  230. package/msg/sco.mjs +30 -1
  231. package/msg/sd.js +32 -3
  232. package/msg/sd.mjs +30 -1
  233. package/msg/shn.js +32 -3
  234. package/msg/shn.mjs +30 -1
  235. package/msg/si.js +33 -4
  236. package/msg/si.mjs +30 -1
  237. package/msg/sk.js +33 -4
  238. package/msg/sk.mjs +30 -1
  239. package/msg/skr-arab.js +35 -6
  240. package/msg/skr-arab.mjs +30 -1
  241. package/msg/sl.js +56 -27
  242. package/msg/sl.mjs +30 -1
  243. package/msg/smn.js +34 -5
  244. package/msg/smn.mjs +30 -1
  245. package/msg/sq.js +41 -12
  246. package/msg/sq.mjs +30 -1
  247. package/msg/sr-latn.js +32 -3
  248. package/msg/sr-latn.mjs +30 -1
  249. package/msg/sr.js +32 -3
  250. package/msg/sr.mjs +30 -1
  251. package/msg/sv.js +55 -26
  252. package/msg/sv.mjs +30 -1
  253. package/msg/sw.js +33 -4
  254. package/msg/sw.mjs +30 -1
  255. package/msg/ta.js +51 -22
  256. package/msg/ta.mjs +30 -1
  257. package/msg/tcy.js +102 -73
  258. package/msg/tcy.mjs +30 -1
  259. package/msg/tdd.js +32 -3
  260. package/msg/tdd.mjs +30 -1
  261. package/msg/te.js +32 -3
  262. package/msg/te.mjs +30 -1
  263. package/msg/th.js +33 -4
  264. package/msg/th.mjs +30 -1
  265. package/msg/ti.js +32 -3
  266. package/msg/ti.mjs +30 -1
  267. package/msg/tl.js +32 -3
  268. package/msg/tl.mjs +30 -1
  269. package/msg/tlh.js +32 -3
  270. package/msg/tlh.mjs +30 -1
  271. package/msg/tr.js +55 -26
  272. package/msg/tr.mjs +30 -1
  273. package/msg/ug-arab.js +32 -3
  274. package/msg/ug-arab.mjs +30 -1
  275. package/msg/uk.js +32 -3
  276. package/msg/uk.mjs +30 -1
  277. package/msg/ur.js +32 -3
  278. package/msg/ur.mjs +30 -1
  279. package/msg/uz.js +47 -18
  280. package/msg/uz.mjs +30 -1
  281. package/msg/vi.js +56 -27
  282. package/msg/vi.mjs +30 -1
  283. package/msg/xmf.js +32 -3
  284. package/msg/xmf.mjs +30 -1
  285. package/msg/yo.js +32 -3
  286. package/msg/yo.mjs +30 -1
  287. package/msg/zgh.js +32 -3
  288. package/msg/zgh.mjs +30 -1
  289. package/msg/zh-hans.js +55 -26
  290. package/msg/zh-hans.mjs +30 -1
  291. package/msg/zh-hant.js +55 -26
  292. package/msg/zh-hant.mjs +30 -1
  293. package/package.json +4 -4
  294. package/php_compressed.js +54 -55
  295. package/php_compressed.js.map +1 -1
  296. package/python_compressed.js +57 -57
  297. package/python_compressed.js.map +1 -1
  298. package/msg/cdo.js +0 -530
package/core/block.d.ts CHANGED
@@ -174,6 +174,8 @@ export declare class Block {
174
174
  type: string;
175
175
  inputsInlineDefault?: boolean;
176
176
  workspace: Workspace;
177
+ /** A custom provider for generating the aria role description for this block. */
178
+ private ariaRoleDescriptionProvider;
177
179
  /**
178
180
  * @param workspace The block's workspace.
179
181
  * @param prototypeName Name of the language object containing type-specific
@@ -695,6 +697,22 @@ export declare class Block {
695
697
  * @param collapsed True if collapsed.
696
698
  */
697
699
  setCollapsed(collapsed: boolean): void;
700
+ /**
701
+ * Set a custom aria role description provider for this block. If not set,
702
+ * uses a default provider based on the block's properties (e.g. whether it has
703
+ * inputs, outputs, etc.).
704
+ *
705
+ * @param description The description or function to provide the description.
706
+ * If a string, we'll replace message references in the string, e.g.
707
+ * `%{BKY_CUSTOM_MESSAGE}` will be replaced with the value of
708
+ * `Blockly.Msg['CUSTOM_MESSAGE']`.}'
709
+ */
710
+ setAriaRoleDescriptionProvider(description: string | (() => string)): void;
711
+ /**
712
+ * @returns The custom string to use as the role description for this block,
713
+ * or undefined if no custom description is set.
714
+ */
715
+ getAriaRoleDescription(): string | undefined;
698
716
  /**
699
717
  * Create a human-readable text representation of this block and any children.
700
718
  *
@@ -4,8 +4,8 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import type { BlockSvg } from './block_svg.js';
7
- import { RenderedConnection } from './blockly.js';
8
7
  import type { Input } from './inputs/input.js';
8
+ import { RenderedConnection } from './rendered_connection.js';
9
9
  import { Verbosity } from './utils/aria.js';
10
10
  /**
11
11
  * Prepositions to use when describing the relationship between two blocks based
@@ -13,6 +13,12 @@ import { Coordinate } from '../utils/coordinate.js';
13
13
  import { Rect } from '../utils/rect.js';
14
14
  import { Size } from '../utils/size.js';
15
15
  import { WorkspaceSvg } from '../workspace_svg.js';
16
+ /**
17
+ * Represents a either a string or a function that, when called, can provide a
18
+ * custom ARIA string to represent a bubble, or null if the default fallback
19
+ * should be used. See setAriaLabelProvider for more context.
20
+ */
21
+ export type AriaLabelProvider = string | ((bubble: Bubble) => string | null);
16
22
  /**
17
23
  * The abstract pop-up bubble class. This creates a UI that looks like a speech
18
24
  * bubble, where it has a "tail" that points to the block, and a "head" that
@@ -66,6 +72,7 @@ export declare abstract class Bubble implements IBubble, ISelectable, IFocusable
66
72
  private relativeLeft;
67
73
  private dragStrategy;
68
74
  private focusableElement;
75
+ private ariaLabelProvider;
69
76
  /**
70
77
  * @param workspace The workspace this bubble belongs to.
71
78
  * @param anchor The anchor location of the thing this bubble is attached to.
@@ -239,5 +246,37 @@ export declare abstract class Bubble implements IBubble, ISelectable, IFocusable
239
246
  * Returns the object that owns/hosts this bubble, if any.
240
247
  */
241
248
  getOwner(): (IHasBubble & IFocusableNode) | undefined;
249
+ /**
250
+ * Recomputes the ARIA label and role for this bubble. This is automatically called
251
+ * during initialization, but implementations may find it useful to call this if
252
+ * the bubble's label should be changed.
253
+ *
254
+ * Bubbles use a default non-specific label unless they're customized otherwise
255
+ * which is the responsibility of the bubble's owner rather than bubble
256
+ * implementations. Customization can be done via setAriaLabelProvider.
257
+ */
258
+ protected recomputeAriaContext(): void;
259
+ /**
260
+ * Sets a custom ARIA label provider for this bubble, or null if it should be reset
261
+ * to use the default method.
262
+ *
263
+ * Bubbles do not compute ARIA labels specifically to their implementation since
264
+ * they can be rather general-purpose. Instead, owners of the specific bubble
265
+ * instance (such as an icon) are responsible for defining custom label providers
266
+ * for their bubbles.
267
+ *
268
+ * Note that calling this isn't sufficient for it to actually be used.
269
+ * recomputeAriaContext will likely also need to be called to actually apply the
270
+ * custom label to the bubble's focusable element.
271
+ */
272
+ setAriaLabelProvider(provider: AriaLabelProvider | null): void;
273
+ /**
274
+ * Returns the ARIA label to use for this bubble based on the provider set via
275
+ * setAriaLabelProvider. This will return null if the provider is absent or
276
+ * returns null.
277
+ *
278
+ * @returns The ARIA label to use for this bubble, or null if one is not provided.
279
+ */
280
+ getAriaLabel(): string | null;
242
281
  }
243
282
  //# sourceMappingURL=bubble.d.ts.map
@@ -43,6 +43,7 @@ export declare class TextInputBubble extends Bubble {
43
43
  private editable;
44
44
  /** View responsible for supporting text editing. */
45
45
  private editor;
46
+ private readonly textChangeListener;
46
47
  /**
47
48
  * @param workspace The workspace this bubble belongs to.
48
49
  * @param anchor The anchor location of the thing this bubble is attached to.
@@ -103,5 +104,9 @@ export declare class TextInputBubble extends Bubble {
103
104
  * the comment editor.
104
105
  */
105
106
  performAction(): void;
107
+ /**
108
+ * Dispose of this bubble.
109
+ */
110
+ dispose(): void;
106
111
  }
107
112
  //# sourceMappingURL=textinput_bubble.d.ts.map
@@ -114,6 +114,29 @@ export declare class FieldCheckbox extends Field<CheckboxBool> {
114
114
  * @returns The converted value.
115
115
  */
116
116
  private convertValueToBool;
117
+ /**
118
+ * Gets an ARIA-friendly label representation of this field's type.
119
+ *
120
+ * Implementations are responsible for, and encouraged to, return a localized
121
+ * version of the ARIA representation of the field's type.
122
+ *
123
+ * @returns An ARIA representation of the field's type or a default if it is
124
+ * unspecified.
125
+ */
126
+ getAriaTypeName(): string;
127
+ /**
128
+ * Gets an ARIA-friendly label representation of this field's value.
129
+ *
130
+ * Implementations are responsible for, and encouraged to, return a localized
131
+ * version of the ARIA representation of the field's value.
132
+ *
133
+ * The FieldCheckbox implementation is not used for the actual ARIA label of
134
+ * the field, since the checked state is already included in the ARIA checked
135
+ * state, but it is used for the ARIA label of its source block.
136
+ *
137
+ * @returns An ARIA representation of the field's text.
138
+ */
139
+ getAriaValue(): string | null;
117
140
  /**
118
141
  * Construct a FieldCheckbox from a JSON arg object.
119
142
  *
@@ -123,6 +146,10 @@ export declare class FieldCheckbox extends Field<CheckboxBool> {
123
146
  * @internal
124
147
  */
125
148
  static fromJson(options: FieldCheckboxFromJsonConfig): FieldCheckbox;
149
+ /**
150
+ * Recomputes the ARIA role and label for this field.
151
+ */
152
+ protected recomputeAriaContext(): void;
126
153
  }
127
154
  /**
128
155
  * Config options for the checkbox field.
@@ -56,6 +56,11 @@ export declare class FieldDropdown extends Field<string> {
56
56
  protected static IMAGE_Y_OFFSET: number;
57
57
  /** The total vertical padding above and below an image. */
58
58
  protected static IMAGE_Y_PADDING: number;
59
+ /**
60
+ * True once the field’s DOM has been created and it is safe to run ARIA
61
+ * updates in response to value changes.
62
+ */
63
+ isInitialized: boolean;
59
64
  /**
60
65
  * @param menuGenerator A non-empty array of options for a dropdown list, or a
61
66
  * function which generates these options. Also accepts Field.SKIP_SETUP
@@ -238,6 +243,50 @@ export declare class FieldDropdown extends Field<string> {
238
243
  * @throws {TypeError} If proposed options are incorrectly structured.
239
244
  */
240
245
  protected validateOptions(options: MenuOption[]): void;
246
+ /**
247
+ * Gets an ARIA-friendly label representation of this field's type.
248
+ *
249
+ * Implementations are responsible for, and encouraged to, return a localized
250
+ * version of the ARIA representation of the field's type.
251
+ *
252
+ * @returns An ARIA representation of the field's type or a default if it is
253
+ * unspecified.
254
+ */
255
+ getAriaTypeName(): string | null;
256
+ /**
257
+ * Gets an ARIA-friendly label representation of this field's value.
258
+ *
259
+ * Implementations are responsible for, and encouraged to, return a localized
260
+ * version of the ARIA representation of the field's value.
261
+ *
262
+ * @returns An ARIA representation of the field's text.
263
+ */
264
+ getAriaValue(): string;
265
+ /**
266
+ * Returns the ARIA label for the currently selected dropdown option.
267
+ *
268
+ * @returns The computed ARIA label for the selected option, or `null` if no
269
+ * option is selected.
270
+ */
271
+ private getSelectedAriaLabel;
272
+ /**
273
+ * Recomputes the ARIA role and label for this field.
274
+ */
275
+ protected recomputeAriaContext(): void;
276
+ /**
277
+ * Computes an ARIA-friendly label for a dropdown option.
278
+ *
279
+ * The label is derived using a prioritized set of sources.
280
+ *
281
+ * Returned values are guaranteed to be non-empty strings for all non-separator
282
+ * options. Whitespace-only values are ignored when determining a usable label.
283
+ *
284
+ * @param option The dropdown option for which to compute the ARIA label.
285
+ * @param index The index of the option within the dropdown (0-based).
286
+ * @returns A string suitable for use as an ARIA label. Returns an empty string
287
+ * only if the option is a separator.
288
+ */
289
+ private computeOptionAriaLabel;
241
290
  }
242
291
  /**
243
292
  * Definition of a human-readable image dropdown option.
@@ -247,6 +296,7 @@ export interface ImageProperties {
247
296
  alt: string;
248
297
  width: number;
249
298
  height: number;
299
+ ariaLabel?: string;
250
300
  }
251
301
  /**
252
302
  * An individual option in the dropdown menu. Can be either the string literal
@@ -255,7 +305,7 @@ export interface ImageProperties {
255
305
  * (text, ImageProperties object, or HTML element), and the second element is
256
306
  * the language-neutral value.
257
307
  */
258
- export type MenuOption = [string | ImageProperties | HTMLElement, string] | 'separator';
308
+ export type MenuOption = [string | ImageProperties | HTMLElement, string, string?] | 'separator';
259
309
  /**
260
310
  * A function that generates an array of menu options for FieldDropdown
261
311
  * or its descendants.
@@ -129,6 +129,30 @@ export declare class FieldImage extends Field<string> {
129
129
  * @internal
130
130
  */
131
131
  static fromJson(options: FieldImageFromJsonConfig): FieldImage;
132
+ /**
133
+ * Gets an ARIA-friendly label representation of this field's type.
134
+ *
135
+ * Implementations are responsible for, and encouraged to, return a localized
136
+ * version of the ARIA representation of the field's type.
137
+ *
138
+ * @returns An ARIA representation of the field's type or a default if it is
139
+ * unspecified.
140
+ */
141
+ getAriaTypeName(): string | null;
142
+ /**
143
+ * Gets an ARIA-friendly label representation of this field's value.
144
+ *
145
+ * Implementations are responsible for, and encouraged to, return a localized
146
+ * version of the ARIA representation of the field's value.
147
+ *
148
+ * @returns An ARIA representation of the field's text, or null if no text is
149
+ * currently defined or known for the field.
150
+ */
151
+ getAriaValue(): string | null;
152
+ /**
153
+ * Recomputes the ARIA role and label for this field.
154
+ */
155
+ protected recomputeAriaContext(): void;
132
156
  }
133
157
  /**
134
158
  * Config options for the image field.
@@ -285,7 +285,7 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
285
285
  /**
286
286
  * Recomputes the ARIA role and label for this field.
287
287
  */
288
- private recomputeAriaContext;
288
+ protected recomputeAriaContext(): void;
289
289
  }
290
290
  /**
291
291
  * Config options for the input field.
@@ -160,6 +160,16 @@ export declare class FieldNumber extends FieldInput<number> {
160
160
  * @internal
161
161
  */
162
162
  static fromJson(options: FieldNumberFromJsonConfig): FieldNumber;
163
+ /**
164
+ * Gets an ARIA-friendly label representation of this field's type.
165
+ *
166
+ * Implementations are responsible for, and encouraged to, return a localized
167
+ * version of the ARIA representation of the field's type.
168
+ *
169
+ * @returns An ARIA representation of the field's type or a default if it is
170
+ * unspecified.
171
+ */
172
+ getAriaTypeName(): string | null;
163
173
  }
164
174
  /**
165
175
  * Config options for the number field.
@@ -48,6 +48,16 @@ export declare class FieldTextInput extends FieldInput<string> {
48
48
  * @internal
49
49
  */
50
50
  static fromJson(options: FieldTextInputFromJsonConfig): FieldTextInput;
51
+ /**
52
+ * Gets an ARIA-friendly label representation of this field's type.
53
+ *
54
+ * Implementations are responsible for, and encouraged to, return a localized
55
+ * version of the ARIA representation of the field's type.
56
+ *
57
+ * @returns An ARIA representation of the field's type or a default if it is
58
+ * unspecified.
59
+ */
60
+ getAriaTypeName(): string | null;
51
61
  }
52
62
  /**
53
63
  * Config options for the text input field.
@@ -228,6 +228,15 @@ export declare class FieldVariable extends FieldDropdown {
228
228
  * @returns Array of variable names/id tuples.
229
229
  */
230
230
  static dropdownCreate(this: FieldVariable): MenuOption[];
231
+ /**
232
+ * Gets an ARIA-friendly label representation of this field's value.
233
+ *
234
+ * Implementations are responsible for, and encouraged to, return a localized
235
+ * version of the ARIA representation of the field's value.
236
+ *
237
+ * @returns An ARIA representation of the field's text.
238
+ */
239
+ getAriaValue(): string;
231
240
  }
232
241
  /**
233
242
  * Config options for the variable field.
@@ -268,6 +268,16 @@ export declare abstract class Flyout extends DeleteArea implements IAutoHideable
268
268
  * toolbox definition, or a string with the name of the dynamic category.
269
269
  */
270
270
  show(flyoutDef: toolbox.FlyoutDefinition | string): void;
271
+ /**
272
+ * Updates the aria attributes for the entire flyout dom.
273
+ * This needs to do two things:
274
+ * 1. Set aria-owns on the flyout's workspace canvas to include the ids of all
275
+ * focusable elements in the flyout.
276
+ * 2. Update the aria attributes on the flyout's workspace. This can't be done at workspace
277
+ * creation because the workspace may not have all required information until the flyout
278
+ * is fully shown.
279
+ */
280
+ protected updateAriaContext(): void;
271
281
  /**
272
282
  * Create the contents array and gaps array necessary to create the layout for
273
283
  * the flyout.
@@ -115,6 +115,14 @@ export declare class CommentIcon extends Icon implements IHasBubble, ISerializab
115
115
  * I.E. the block that owns this icon.
116
116
  */
117
117
  private getBubbleOwnerRect;
118
+ /**
119
+ * Returns the ARIA label to use for this icon (defaults to null). Note that this
120
+ * method will only be called during initialization by default, so dynamic changes
121
+ * to the icon's ARIA label need to be applied by calling recomputeAriaContext.
122
+ *
123
+ * @returns The ARIA label to use for this icon, or null to use a default.
124
+ */
125
+ protected getAriaLabel(): string | null;
118
126
  }
119
127
  /** The save state format for a comment icon. */
120
128
  export interface CommentState {
@@ -86,5 +86,19 @@ export declare abstract class Icon implements IIcon, IContextMenu {
86
86
  */
87
87
  getSourceBlock(): Block;
88
88
  showContextMenu(e: PointerEvent): void;
89
+ /**
90
+ * Recomputes the ARIA label and role for this icon. This is automatically called
91
+ * during initialization, but implementations may find it useful to call this if
92
+ * the icon's label should be changed.
93
+ */
94
+ protected recomputeAriaContext(): void;
95
+ /**
96
+ * Returns the ARIA label to use for this icon (defaults to null). Note that this
97
+ * method will only be called during initialization by default, so dynamic changes
98
+ * to the icon's ARIA label need to be applied by calling recomputeAriaContext.
99
+ *
100
+ * @returns The ARIA label to use for this icon, or null to use a default.
101
+ */
102
+ protected getAriaLabel(): string | null;
89
103
  }
90
104
  //# sourceMappingURL=icon.d.ts.map
@@ -92,5 +92,13 @@ export declare class MutatorIcon extends Icon implements IHasBubble {
92
92
  * currently open.
93
93
  */
94
94
  getWorkspace(): WorkspaceSvg | undefined;
95
+ /**
96
+ * Returns the ARIA label to use for this icon (defaults to null). Note that this
97
+ * method will only be called during initialization by default, so dynamic changes
98
+ * to the icon's ARIA label need to be applied by calling recomputeAriaContext.
99
+ *
100
+ * @returns The ARIA label to use for this icon, or null to use a default.
101
+ */
102
+ protected getAriaLabel(): string | null;
95
103
  }
96
104
  //# sourceMappingURL=mutator_icon.d.ts.map
@@ -73,5 +73,13 @@ export declare class WarningIcon extends Icon implements IHasBubble {
73
73
  * I.E. the block that owns this icon.
74
74
  */
75
75
  private getBubbleOwnerRect;
76
+ /**
77
+ * Returns the ARIA label to use for this icon (defaults to null). Note that this
78
+ * method will only be called during initialization by default, so dynamic changes
79
+ * to the icon's ARIA label need to be applied by calling recomputeAriaContext.
80
+ *
81
+ * @returns The ARIA label to use for this icon, or null to use a default.
82
+ */
83
+ protected getAriaLabel(): string | null;
76
84
  }
77
85
  //# sourceMappingURL=warning_icon.d.ts.map
@@ -17,6 +17,12 @@ import type { Field } from '../field.js';
17
17
  import { Verbosity } from '../utils/aria.js';
18
18
  import { Align } from './align.js';
19
19
  import { inputTypes } from './input_types.js';
20
+ /**
21
+ * Represents a string or a function that returns a string which can be used as a
22
+ * custom ARIA string to represent an Input, or null if the default fallback should
23
+ * be used. See setAriaLabelProvider for more context.
24
+ */
25
+ export type AriaLabelProvider = ((input: Input) => string | null) | string;
20
26
  /** Class for an input with optional fields. */
21
27
  export declare class Input {
22
28
  name: string;
@@ -26,6 +32,8 @@ export declare class Input {
26
32
  align: Align;
27
33
  /** Is the input visible? */
28
34
  private visible;
35
+ /** The AriaLabelProvider */
36
+ private ariaLabelProvider;
29
37
  readonly type: inputTypes;
30
38
  connection: Connection | null;
31
39
  /**
@@ -123,6 +131,26 @@ export declare class Input {
123
131
  getShadowDom(): Element | null;
124
132
  /** Initialize the fields on this input. */
125
133
  init(): void;
134
+ /**
135
+ * Sets a custom ARIA label provider for this input, or null if it should be reset
136
+ * to use the default method.
137
+ *
138
+ * Inputs do not compute ARIA contexts directly, so the set provider will be used
139
+ * in select cases when the Input needs to be represented (such as for parts of a
140
+ * block label or for connections). Note that overriding this provider will not
141
+ * recompute any already constructed ARIA labels, and it cannot be assumed that the
142
+ * provider will be called any particular number of times during label
143
+ * recomputation. As such, implementations should make sure to provide a
144
+ * deterministic and idempotent ARIA representation each time the provider is
145
+ * called for a given input. It's also fine to reuse providers across multiple
146
+ * Input implementations.
147
+ */
148
+ setAriaLabelProvider(provider: AriaLabelProvider | null): void;
149
+ /**
150
+ * Returns the string from the custom ARIA label provider set, or null if the default label (from the field row) should
151
+ * be used. See setAriaLabelProvider for more context.
152
+ */
153
+ getAriaLabelText(): string | null;
126
154
  /**
127
155
  * Initializes the fields on this input for a headless block.
128
156
  *
@@ -7,6 +7,15 @@ export interface IFlyoutInflater {
7
7
  * Note that this method's interface is identical to that in ISerializer, to
8
8
  * allow for code reuse.
9
9
  *
10
+ * You must ensure that any item created by this method has the appropriate
11
+ * ARIA markup:
12
+ * - The role of the element's focusable element should be set to `listitem`.
13
+ * - The focusable element must have an `id` attribute.
14
+ * - Any DOM parents of the focusable element should set their role to
15
+ * `presentation` to avoid interfering with flyout list navigation.
16
+ * - If the element is not focusable, it must be hidden from the ARIA tree.
17
+ * Only do this if the content should be inaccessible to screenreaders.
18
+ *
10
19
  * @param state A JSON representation of an element to inflate on the flyout.
11
20
  * @param flyout The flyout on whose workspace the inflated element
12
21
  * should be created. If the inflated element is an `IRenderedElement` it
@@ -40,6 +40,7 @@ export interface JsonBlockDefinition {
40
40
  inputsInline?: boolean;
41
41
  tooltip?: string;
42
42
  helpUrl?: string;
43
+ ariaRoleDescription?: string;
43
44
  extensions?: string[];
44
45
  mutator?: string;
45
46
  enableContextMenu?: boolean;
package/core/menu.d.ts CHANGED
@@ -41,6 +41,8 @@ export declare class Menu {
41
41
  private element;
42
42
  /** ARIA name for this menu. */
43
43
  private roleName;
44
+ /** The menu's ID. */
45
+ private id;
44
46
  /** Constructs a new Menu instance. */
45
47
  constructor();
46
48
  /**
@@ -166,5 +168,6 @@ export declare class Menu {
166
168
  * @returns The MenuItem objects displayed in this menu.
167
169
  */
168
170
  private getMenuItems;
171
+ getId(): string;
169
172
  }
170
173
  //# sourceMappingURL=menu.d.ts.map
@@ -15,6 +15,7 @@ import * as aria from './utils/aria.js';
15
15
  export declare class MenuItem {
16
16
  private readonly content;
17
17
  private readonly opt_value?;
18
+ private readonly ariaLabel?;
18
19
  /** Is the menu item clickable, as opposed to greyed-out. */
19
20
  private enabled;
20
21
  /** The DOM element for the menu item. */
@@ -31,18 +32,24 @@ export declare class MenuItem {
31
32
  private highlight;
32
33
  /** Bound function to call when this menu item is clicked. */
33
34
  private actionHandler;
35
+ /** The unique ID for this menu item. */
36
+ private id;
34
37
  /**
35
38
  * @param content Text caption to display as the content of the item, or a
36
39
  * HTML element to display.
37
40
  * @param opt_value Data/model associated with the menu item.
38
41
  */
39
- constructor(content: string | HTMLElement, opt_value?: string | undefined);
42
+ constructor(content: string | HTMLElement, opt_value?: string | undefined, ariaLabel?: string | undefined);
40
43
  /**
41
44
  * Creates the menuitem's DOM.
42
45
  *
43
46
  * @returns Completed DOM.
44
47
  */
45
48
  createDom(): Element;
49
+ /**
50
+ * Gets the ARIA label for this menu item.
51
+ */
52
+ getAriaLabel(): string;
46
53
  /** Dispose of this menu item. */
47
54
  dispose(): void;
48
55
  /**
@@ -35,7 +35,8 @@ export declare enum names {
35
35
  INFORMATION = "information",
36
36
  PERFORM_ACTION = "perform_action",
37
37
  DUPLICATE = "duplicate",
38
- CLEANUP = "cleanup"
38
+ CLEANUP = "cleanup",
39
+ SHOW_TOOLTIP = "show_tooltip"
39
40
  }
40
41
  /**
41
42
  * Keyboard shortcut to hide chaff on escape.
@@ -112,6 +113,10 @@ export declare function registerDuplicate(): void;
112
113
  * Registers keyboard shortcut to clean up the workspace.
113
114
  */
114
115
  export declare function registerCleanup(): void;
116
+ /**
117
+ * Registers keyboard shortcut to display the tooltip for the focused element.
118
+ */
119
+ export declare function registerShowTooltip(): void;
115
120
  /**
116
121
  * Registers all default keyboard shortcut item. This should be called once per
117
122
  * instance of KeyboardShortcutRegistry.
package/core/tooltip.d.ts CHANGED
@@ -3,6 +3,8 @@
3
3
  * Copyright 2011 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import type { IFocusableNode } from './interfaces/i_focusable_node.js';
7
+ import type { WorkspaceSvg } from './workspace_svg.js';
6
8
  /**
7
9
  * A type which can define a tooltip.
8
10
  * Either a string, an object containing a tooltip property, or a function which
@@ -101,6 +103,14 @@ export declare function dispose(): void;
101
103
  * Hide the tooltip.
102
104
  */
103
105
  export declare function hide(): void;
106
+ /**
107
+ * Display the tooltip for a given target.
108
+ *
109
+ * @internal
110
+ * @param target The node upon which the tooltip should be displayed.
111
+ * @param workspace The target node's workspace.
112
+ */
113
+ export declare function display(target: IFocusableNode, workspace?: WorkspaceSvg): void;
104
114
  /**
105
115
  * Hide any in-progress tooltips and block showing new tooltips until the next
106
116
  * call to unblock().