blockly 9.2.1 → 9.3.0

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 (299) hide show
  1. package/blockly.min.js +1615 -1509
  2. package/blockly_compressed.js +1249 -1136
  3. package/blockly_compressed.js.map +1 -1
  4. package/blocks_compressed.js +166 -173
  5. package/blocks_compressed.js.map +1 -1
  6. package/core/any_aliases.d.ts +5 -0
  7. package/core/block.d.ts +49 -17
  8. package/core/block_animations.d.ts +0 -4
  9. package/core/block_dragger.d.ts +1 -6
  10. package/core/block_svg.d.ts +58 -8
  11. package/core/blockly.d.ts +27 -58
  12. package/core/blockly_options.d.ts +0 -2
  13. package/core/blocks.d.ts +0 -2
  14. package/core/browser_events.d.ts +0 -9
  15. package/core/bubble.d.ts +0 -2
  16. package/core/bubble_dragger.d.ts +0 -2
  17. package/core/bump_objects.d.ts +0 -3
  18. package/core/clipboard.d.ts +0 -3
  19. package/core/comment.d.ts +6 -10
  20. package/core/common.d.ts +0 -12
  21. package/core/component_manager.d.ts +0 -2
  22. package/core/connection.d.ts +19 -6
  23. package/core/connection_checker.d.ts +1 -3
  24. package/core/connection_db.d.ts +0 -2
  25. package/core/connection_type.d.ts +0 -2
  26. package/core/constants.d.ts +0 -4
  27. package/core/contextmenu.d.ts +0 -11
  28. package/core/contextmenu_items.d.ts +0 -27
  29. package/core/contextmenu_registry.d.ts +0 -2
  30. package/core/css.d.ts +0 -2
  31. package/core/delete_area.d.ts +0 -2
  32. package/core/dialog.d.ts +0 -6
  33. package/core/drag_target.d.ts +0 -2
  34. package/core/events/events.d.ts +2 -22
  35. package/core/events/events_abstract.d.ts +7 -3
  36. package/core/events/events_block_base.d.ts +2 -3
  37. package/core/events/events_block_change.d.ts +9 -3
  38. package/core/events/events_block_create.d.ts +6 -4
  39. package/core/events/events_block_delete.d.ts +7 -4
  40. package/core/events/events_block_drag.d.ts +7 -3
  41. package/core/events/events_block_move.d.ts +20 -3
  42. package/core/events/events_bubble_open.d.ts +3 -2
  43. package/core/events/events_click.d.ts +6 -3
  44. package/core/events/events_comment_base.d.ts +1 -2
  45. package/core/events/events_comment_change.d.ts +3 -3
  46. package/core/events/events_comment_create.d.ts +2 -3
  47. package/core/events/events_comment_delete.d.ts +2 -3
  48. package/core/events/events_comment_move.d.ts +4 -4
  49. package/core/events/events_marker_move.d.ts +10 -3
  50. package/core/events/events_selected.d.ts +6 -2
  51. package/core/events/events_theme_change.d.ts +2 -3
  52. package/core/events/events_toolbox_item_select.d.ts +3 -3
  53. package/core/events/events_trashcan_open.d.ts +5 -3
  54. package/core/events/events_ui.d.ts +0 -1
  55. package/core/events/events_ui_base.d.ts +0 -2
  56. package/core/events/events_var_base.d.ts +1 -2
  57. package/core/events/events_var_create.d.ts +3 -3
  58. package/core/events/events_var_delete.d.ts +4 -2
  59. package/core/events/events_var_rename.d.ts +4 -2
  60. package/core/events/events_viewport.d.ts +13 -2
  61. package/core/events/utils.d.ts +0 -89
  62. package/core/events/workspace_events.d.ts +2 -6
  63. package/core/extensions.d.ts +0 -8
  64. package/core/field.d.ts +55 -21
  65. package/core/field_angle.d.ts +61 -51
  66. package/core/field_checkbox.d.ts +34 -15
  67. package/core/field_colour.d.ts +56 -46
  68. package/core/field_dropdown.d.ts +35 -19
  69. package/core/field_image.d.ts +10 -14
  70. package/core/field_input.d.ts +39 -25
  71. package/core/field_label.d.ts +7 -10
  72. package/core/field_label_serializable.d.ts +4 -6
  73. package/core/field_multilineinput.d.ts +36 -14
  74. package/core/field_number.d.ts +27 -19
  75. package/core/field_registry.d.ts +0 -3
  76. package/core/field_textinput.d.ts +36 -8
  77. package/core/field_variable.d.ts +30 -18
  78. package/core/flyout_base.d.ts +5 -6
  79. package/core/flyout_button.d.ts +2 -2
  80. package/core/flyout_horizontal.d.ts +0 -2
  81. package/core/flyout_metrics_manager.d.ts +0 -2
  82. package/core/flyout_vertical.d.ts +0 -2
  83. package/core/generator.d.ts +0 -1
  84. package/core/gesture.d.ts +5 -18
  85. package/core/grid.d.ts +0 -2
  86. package/core/icon.d.ts +0 -2
  87. package/core/inject.d.ts +0 -1
  88. package/core/input.d.ts +0 -3
  89. package/core/input_types.d.ts +0 -2
  90. package/core/insertion_marker_manager.d.ts +6 -6
  91. package/core/interfaces/i_ast_node_location.d.ts +0 -2
  92. package/core/interfaces/i_ast_node_location_svg.d.ts +0 -2
  93. package/core/interfaces/i_ast_node_location_with_block.d.ts +0 -2
  94. package/core/interfaces/i_autohideable.d.ts +0 -2
  95. package/core/interfaces/i_block_dragger.d.ts +0 -2
  96. package/core/interfaces/i_bounded_element.d.ts +0 -2
  97. package/core/interfaces/i_bubble.d.ts +0 -2
  98. package/core/interfaces/i_collapsible_toolbox_item.d.ts +0 -2
  99. package/core/interfaces/i_component.d.ts +0 -2
  100. package/core/interfaces/i_connection_checker.d.ts +0 -2
  101. package/core/interfaces/i_contextmenu.d.ts +0 -1
  102. package/core/interfaces/i_copyable.d.ts +3 -2
  103. package/core/interfaces/i_deletable.d.ts +0 -2
  104. package/core/interfaces/i_delete_area.d.ts +0 -2
  105. package/core/interfaces/i_drag_target.d.ts +0 -2
  106. package/core/interfaces/i_draggable.d.ts +0 -2
  107. package/core/interfaces/i_flyout.d.ts +0 -2
  108. package/core/interfaces/i_keyboard_accessible.d.ts +0 -2
  109. package/core/interfaces/i_legacy_procedure_blocks.d.ts +34 -0
  110. package/core/interfaces/i_metrics_manager.d.ts +8 -8
  111. package/core/interfaces/i_movable.d.ts +0 -2
  112. package/core/interfaces/i_positionable.d.ts +0 -2
  113. package/core/interfaces/i_procedure_block.d.ts +3 -0
  114. package/core/interfaces/i_procedure_model.d.ts +0 -5
  115. package/core/interfaces/i_registrable.d.ts +0 -2
  116. package/core/interfaces/i_selectable.d.ts +0 -2
  117. package/core/interfaces/i_selectable_toolbox_item.d.ts +4 -2
  118. package/core/interfaces/i_serializer.d.ts +0 -2
  119. package/core/interfaces/i_styleable.d.ts +0 -2
  120. package/core/interfaces/i_toolbox.d.ts +0 -2
  121. package/core/interfaces/i_toolbox_item.d.ts +0 -2
  122. package/core/interfaces/i_variable_backed_parameter_model.d.ts +17 -0
  123. package/core/internal_constants.d.ts +0 -5
  124. package/core/keyboard_nav/ast_node.d.ts +0 -3
  125. package/core/keyboard_nav/basic_cursor.d.ts +0 -3
  126. package/core/keyboard_nav/cursor.d.ts +0 -3
  127. package/core/keyboard_nav/marker.d.ts +0 -2
  128. package/core/keyboard_nav/tab_navigate_cursor.d.ts +0 -2
  129. package/core/marker_manager.d.ts +0 -2
  130. package/core/menu.d.ts +0 -2
  131. package/core/menuitem.d.ts +0 -2
  132. package/core/metrics_manager.d.ts +8 -8
  133. package/core/mutator.d.ts +0 -2
  134. package/core/names.d.ts +0 -3
  135. package/core/{procedures/observable_procedure_map.d.ts → observable_procedure_map.d.ts} +4 -5
  136. package/core/options.d.ts +0 -2
  137. package/core/positionable_helpers.d.ts +0 -7
  138. package/core/procedures.d.ts +7 -28
  139. package/core/registry.d.ts +0 -11
  140. package/core/render_management.d.ts +15 -0
  141. package/core/rendered_connection.d.ts +22 -9
  142. package/core/renderers/common/block_rendering.d.ts +0 -3
  143. package/core/renderers/common/constants.d.ts +6 -51
  144. package/core/renderers/common/debug.d.ts +0 -3
  145. package/core/renderers/common/debugger.d.ts +9 -23
  146. package/core/renderers/common/drawer.d.ts +0 -5
  147. package/core/renderers/common/i_path_object.d.ts +0 -17
  148. package/core/renderers/common/info.d.ts +2 -12
  149. package/core/renderers/common/marker_svg.d.ts +2 -4
  150. package/core/renderers/common/path_object.d.ts +0 -24
  151. package/core/renderers/common/renderer.d.ts +5 -20
  152. package/core/renderers/geras/constants.d.ts +0 -5
  153. package/core/renderers/geras/drawer.d.ts +2 -4
  154. package/core/renderers/geras/highlight_constants.d.ts +6 -17
  155. package/core/renderers/geras/highlighter.d.ts +0 -13
  156. package/core/renderers/geras/info.d.ts +2 -5
  157. package/core/renderers/geras/measurables/inline_input.d.ts +0 -3
  158. package/core/renderers/geras/measurables/statement_input.d.ts +0 -3
  159. package/core/renderers/geras/path_object.d.ts +0 -8
  160. package/core/renderers/geras/renderer.d.ts +5 -7
  161. package/core/renderers/measurables/base.d.ts +0 -3
  162. package/core/renderers/measurables/bottom_row.d.ts +0 -9
  163. package/core/renderers/measurables/connection.d.ts +0 -3
  164. package/core/renderers/measurables/external_value_input.d.ts +0 -3
  165. package/core/renderers/measurables/field.d.ts +0 -3
  166. package/core/renderers/measurables/hat.d.ts +0 -3
  167. package/core/renderers/measurables/icon.d.ts +2 -5
  168. package/core/renderers/measurables/in_row_spacer.d.ts +0 -3
  169. package/core/renderers/measurables/inline_input.d.ts +1 -4
  170. package/core/renderers/measurables/input_connection.d.ts +1 -4
  171. package/core/renderers/measurables/input_row.d.ts +0 -7
  172. package/core/renderers/measurables/jagged_edge.d.ts +2 -5
  173. package/core/renderers/measurables/next_connection.d.ts +0 -3
  174. package/core/renderers/measurables/output_connection.d.ts +0 -3
  175. package/core/renderers/measurables/previous_connection.d.ts +0 -3
  176. package/core/renderers/measurables/round_corner.d.ts +0 -3
  177. package/core/renderers/measurables/row.d.ts +0 -39
  178. package/core/renderers/measurables/spacer_row.d.ts +0 -3
  179. package/core/renderers/measurables/square_corner.d.ts +0 -3
  180. package/core/renderers/measurables/statement_input.d.ts +0 -3
  181. package/core/renderers/measurables/top_row.d.ts +0 -6
  182. package/core/renderers/measurables/types.d.ts +0 -31
  183. package/core/renderers/minimalist/constants.d.ts +2 -4
  184. package/core/renderers/minimalist/drawer.d.ts +0 -3
  185. package/core/renderers/minimalist/info.d.ts +0 -4
  186. package/core/renderers/minimalist/renderer.d.ts +0 -3
  187. package/core/renderers/thrasos/info.d.ts +0 -4
  188. package/core/renderers/thrasos/renderer.d.ts +3 -3
  189. package/core/renderers/zelos/constants.d.ts +3 -17
  190. package/core/renderers/zelos/drawer.d.ts +0 -3
  191. package/core/renderers/zelos/info.d.ts +0 -4
  192. package/core/renderers/zelos/marker_svg.d.ts +0 -2
  193. package/core/renderers/zelos/measurables/bottom_row.d.ts +0 -3
  194. package/core/renderers/zelos/measurables/inputs.d.ts +0 -3
  195. package/core/renderers/zelos/measurables/row_elements.d.ts +0 -3
  196. package/core/renderers/zelos/measurables/top_row.d.ts +0 -3
  197. package/core/renderers/zelos/path_object.d.ts +0 -9
  198. package/core/renderers/zelos/renderer.d.ts +3 -5
  199. package/core/scrollbar.d.ts +0 -2
  200. package/core/scrollbar_pair.d.ts +0 -2
  201. package/core/serialization/blocks.d.ts +3 -9
  202. package/core/serialization/exceptions.d.ts +0 -8
  203. package/core/serialization/priorities.d.ts +0 -4
  204. package/core/serialization/procedures.d.ts +0 -7
  205. package/core/serialization/registry.d.ts +0 -2
  206. package/core/serialization/variables.d.ts +0 -4
  207. package/core/serialization/workspaces.d.ts +0 -2
  208. package/core/shortcut_items.d.ts +0 -17
  209. package/core/shortcut_registry.d.ts +0 -2
  210. package/core/sprites.d.ts +0 -2
  211. package/core/theme/classic.d.ts +0 -2
  212. package/core/theme/zelos.d.ts +0 -2
  213. package/core/theme.d.ts +0 -2
  214. package/core/theme_manager.d.ts +3 -6
  215. package/core/toolbox/category.d.ts +5 -7
  216. package/core/toolbox/collapsible_category.d.ts +0 -4
  217. package/core/toolbox/separator.d.ts +0 -2
  218. package/core/toolbox/toolbox.d.ts +2 -5
  219. package/core/toolbox/toolbox_item.d.ts +0 -2
  220. package/core/tooltip.d.ts +0 -29
  221. package/core/touch.d.ts +0 -13
  222. package/core/trashcan.d.ts +0 -2
  223. package/core/utils/aria.d.ts +0 -6
  224. package/core/utils/array.d.ts +0 -1
  225. package/core/utils/colour.d.ts +0 -12
  226. package/core/utils/coordinate.d.ts +0 -2
  227. package/core/utils/deprecation.d.ts +0 -1
  228. package/core/utils/dom.d.ts +0 -25
  229. package/core/utils/idgenerator.d.ts +0 -2
  230. package/core/utils/keycodes.d.ts +0 -2
  231. package/core/utils/math.d.ts +0 -3
  232. package/core/utils/metrics.d.ts +0 -1
  233. package/core/utils/object.d.ts +0 -4
  234. package/core/utils/parsing.d.ts +0 -4
  235. package/core/utils/rect.d.ts +0 -2
  236. package/core/utils/size.d.ts +0 -2
  237. package/core/utils/string.d.ts +0 -6
  238. package/core/utils/style.d.ts +0 -8
  239. package/core/utils/svg.d.ts +0 -2
  240. package/core/utils/svg_math.d.ts +0 -6
  241. package/core/utils/svg_paths.d.ts +0 -8
  242. package/core/utils/toolbox.d.ts +2 -35
  243. package/core/utils/useragent.d.ts +0 -8
  244. package/core/utils/xml.d.ts +9 -8
  245. package/core/utils.d.ts +0 -12
  246. package/core/variable_map.d.ts +1 -3
  247. package/core/variable_model.d.ts +0 -1
  248. package/core/variables.d.ts +13 -17
  249. package/core/variables_dynamic.d.ts +0 -4
  250. package/core/warning.d.ts +0 -2
  251. package/core/widgetdiv.d.ts +0 -10
  252. package/core/workspace.d.ts +3 -3
  253. package/core/workspace_audio.d.ts +0 -2
  254. package/core/workspace_comment.d.ts +1 -3
  255. package/core/workspace_comment_svg.d.ts +1 -3
  256. package/core/workspace_dragger.d.ts +0 -2
  257. package/core/workspace_svg.d.ts +4 -7
  258. package/core/xml.d.ts +1 -13
  259. package/core/zoom_controls.d.ts +4 -15
  260. package/dart_compressed.js +199 -199
  261. package/dart_compressed.js.map +1 -1
  262. package/javascript_compressed.js +168 -168
  263. package/javascript_compressed.js.map +1 -1
  264. package/lua_compressed.js +211 -211
  265. package/lua_compressed.js.map +1 -1
  266. package/msg/bn.js +2 -2
  267. package/msg/bs.js +7 -7
  268. package/msg/de.js +1 -1
  269. package/msg/fi.js +1 -1
  270. package/msg/fr.js +3 -3
  271. package/msg/ia.js +5 -5
  272. package/msg/kn.js +5 -5
  273. package/msg/ko.js +1 -1
  274. package/msg/lb.js +22 -22
  275. package/msg/sd.js +9 -9
  276. package/msg/skr-arab.js +2 -2
  277. package/msg/sl.js +18 -18
  278. package/msg/sw.js +1 -1
  279. package/msg/zh-hans.js +6 -6
  280. package/msg/zh-hant.js +2 -2
  281. package/package.json +9 -9
  282. package/php_compressed.js +185 -185
  283. package/php_compressed.js.map +1 -1
  284. package/python_compressed.js +138 -138
  285. package/python_compressed.js.map +1 -1
  286. package/core/events/events_procedure_base.d.ts +0 -26
  287. package/core/events/events_procedure_change_return.d.ts +0 -40
  288. package/core/events/events_procedure_create.d.ts +0 -34
  289. package/core/events/events_procedure_delete.d.ts +0 -32
  290. package/core/events/events_procedure_enable.d.ts +0 -34
  291. package/core/events/events_procedure_parameter_base.d.ts +0 -26
  292. package/core/events/events_procedure_parameter_create.d.ts +0 -42
  293. package/core/events/events_procedure_parameter_delete.d.ts +0 -41
  294. package/core/events/events_procedure_parameter_rename.d.ts +0 -36
  295. package/core/events/events_procedure_rename.d.ts +0 -35
  296. package/core/procedures/observable_parameter_model.d.ts +0 -62
  297. package/core/procedures/observable_procedure_model.d.ts +0 -75
  298. package/core/procedures/update_procedures.d.ts +0 -13
  299. package/core/utils/sentinel.d.ts +0 -13
@@ -3,22 +3,19 @@
3
3
  * Copyright 2013 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { Field } from './field.js';
6
7
  import { FieldInput, FieldInputConfig, FieldInputValidator } from './field_input.js';
7
- import type { Sentinel } from './utils/sentinel.js';
8
- export type FieldAngleValidator = FieldInputValidator<number>;
9
8
  /**
10
9
  * Class for an editable angle field.
11
- *
12
- * @alias Blockly.FieldAngle
13
10
  */
14
11
  export declare class FieldAngle extends FieldInput<number> {
15
- /**
16
- * The default amount to round angles to when using a mouse or keyboard nav
17
- * input. Must be a positive integer to support keyboard navigation.
18
- */
19
- static readonly ROUND = 15;
20
12
  /** Half the width of protractor image. */
21
13
  static readonly HALF: number;
14
+ /**
15
+ * Radius of protractor circle. Slightly smaller than protractor size since
16
+ * otherwise SVG crops off half the border at the edges.
17
+ */
18
+ static readonly RADIUS: number;
22
19
  /**
23
20
  * Default property describing which direction makes an angle field's value
24
21
  * increase. Angle increases clockwise (true) or counterclockwise (false).
@@ -36,60 +33,53 @@ export declare class FieldAngle extends FieldInput<number> {
36
33
  */
37
34
  static readonly WRAP = 360;
38
35
  /**
39
- * Radius of protractor circle. Slightly smaller than protractor size since
40
- * otherwise SVG crops off half the border at the edges.
36
+ * The default amount to round angles to when using a mouse or keyboard nav
37
+ * input. Must be a positive integer to support keyboard navigation.
41
38
  */
42
- static readonly RADIUS: number;
39
+ static readonly ROUND = 15;
43
40
  /**
44
41
  * Whether the angle should increase as the angle picker is moved clockwise
45
42
  * (true) or counterclockwise (false).
46
43
  */
47
- private clockwise_;
44
+ private clockwise;
48
45
  /**
49
46
  * The offset of zero degrees (and all other angles).
50
47
  */
51
- private offset_;
48
+ private offset;
52
49
  /**
53
50
  * The maximum angle to allow before wrapping.
54
51
  */
55
- private wrap_;
52
+ private wrap;
56
53
  /**
57
54
  * The amount to round angles to when using a mouse or keyboard nav input.
58
55
  */
59
- private round_;
60
- /** The angle picker's SVG element. */
61
- private editor_;
62
- /** The angle picker's gauge path depending on the value. */
63
- gauge_: SVGPathElement | null;
64
- /** The angle picker's line drawn representing the value's angle. */
65
- line_: SVGLineElement | null;
66
- /** The degree symbol for this field. */
67
- protected symbol_: SVGTSpanElement;
68
- /** Wrapper click event data. */
69
- private clickWrapper_;
70
- /** Surface click event data. */
71
- private clickSurfaceWrapper_;
72
- /** Surface mouse move event data. */
73
- private moveSurfaceWrapper_;
56
+ private round;
74
57
  /**
75
- * Serializable fields are saved by the serializer, non-serializable fields
76
- * are not. Editable fields should also be serializable.
58
+ * Array holding info needed to unbind events.
59
+ * Used for disposing.
60
+ * Ex: [[node, name, func], [node, name, func]].
77
61
  */
78
- SERIALIZABLE: boolean;
62
+ private boundEvents;
63
+ /** Dynamic red line pointing at the value's angle. */
64
+ private line;
65
+ /** Dynamic pink area extending from 0 to the value's angle. */
66
+ private gauge;
67
+ /** The degree symbol for this field. */
68
+ protected symbol_: SVGTSpanElement | null;
79
69
  /**
80
- * @param opt_value The initial value of the field. Should cast to a number.
70
+ * @param value The initial value of the field. Should cast to a number.
81
71
  * Defaults to 0. Also accepts Field.SKIP_SETUP if you wish to skip setup
82
72
  * (only used by subclasses that want to handle configuration and setting
83
73
  * the field value after their own constructors have run).
84
- * @param opt_validator A function that is called to validate changes to the
74
+ * @param validator A function that is called to validate changes to the
85
75
  * field's value. Takes in a number & returns a validated number, or null
86
76
  * to abort the change.
87
- * @param opt_config A map of options used to configure the field.
77
+ * @param config A map of options used to configure the field.
88
78
  * See the [field creation documentation]{@link
89
79
  * https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/angle#creation}
90
80
  * for a list of properties this parameter supports.
91
81
  */
92
- constructor(opt_value?: string | number | Sentinel, opt_validator?: FieldAngleValidator, opt_config?: FieldAngleConfig);
82
+ constructor(value?: string | number | typeof Field.SKIP_SETUP, validator?: FieldAngleValidator, config?: FieldAngleConfig);
93
83
  /**
94
84
  * Configure the field based on the given map of options.
95
85
  *
@@ -102,21 +92,25 @@ export declare class FieldAngle extends FieldInput<number> {
102
92
  * @internal
103
93
  */
104
94
  initView(): void;
105
- /** Updates the graph when the field rerenders. */
95
+ /** Updates the angle when the field rerenders. */
106
96
  protected render_(): void;
107
97
  /**
108
98
  * Create and show the angle field's editor.
109
99
  *
110
- * @param opt_e Optional mouse event that triggered the field to open, or
111
- * undefined if triggered programmatically.
100
+ * @param e Optional mouse event that triggered the field to open,
101
+ * or undefined if triggered programmatically.
102
+ */
103
+ protected showEditor_(e?: Event): void;
104
+ /**
105
+ * Creates the angle dropdown editor.
106
+ *
107
+ * @returns The newly created slider.
112
108
  */
113
- protected showEditor_(opt_e?: Event): void;
114
- /** Create the angle dropdown editor. */
115
- private dropdownCreate_;
109
+ private dropdownCreate;
116
110
  /** Disposes of events and DOM-references belonging to the angle editor. */
117
- private dropdownDispose_;
111
+ private dropdownDispose;
118
112
  /** Hide the editor. */
119
- private hide_;
113
+ private hide;
120
114
  /**
121
115
  * Set the angle to match the mouse's position.
122
116
  *
@@ -130,29 +124,29 @@ export declare class FieldAngle extends FieldInput<number> {
130
124
  *
131
125
  * @param angle New angle.
132
126
  */
133
- private displayMouseOrKeyboardValue_;
127
+ private displayMouseOrKeyboardValue;
134
128
  /** Redraw the graph with the current angle. */
135
- private updateGraph_;
129
+ private updateGraph;
136
130
  /**
137
131
  * Handle key down to the editor.
138
132
  *
139
133
  * @param e Keyboard event.
140
134
  */
141
- protected onHtmlInputKeyDown_(e: Event): void;
135
+ protected onHtmlInputKeyDown_(e: KeyboardEvent): void;
142
136
  /**
143
137
  * Ensure that the input value is a valid angle.
144
138
  *
145
- * @param opt_newValue The input value.
139
+ * @param newValue The input value.
146
140
  * @returns A valid angle, or null if invalid.
147
141
  */
148
- protected doClassValidation_(opt_newValue?: any): number | null;
142
+ protected doClassValidation_(newValue?: any): number | null;
149
143
  /**
150
144
  * Wraps the value so that it is in the range (-360 + wrap, wrap).
151
145
  *
152
146
  * @param value The value to wrap.
153
147
  * @returns The wrapped value.
154
148
  */
155
- private wrapValue_;
149
+ private wrapValue;
156
150
  /**
157
151
  * Construct a FieldAngle from a JSON arg object.
158
152
  *
@@ -197,4 +191,20 @@ export interface FieldAngleConfig extends FieldInputConfig {
197
191
  export interface FieldAngleFromJsonConfig extends FieldAngleConfig {
198
192
  angle?: number;
199
193
  }
194
+ /**
195
+ * A function that is called to validate changes to the field's value before
196
+ * they are set.
197
+ *
198
+ * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}
199
+ * @param newValue The value to be validated.
200
+ * @returns One of three instructions for setting the new value: `T`, `null`,
201
+ * or `undefined`.
202
+ *
203
+ * - `T` to set this function's returned value instead of `newValue`.
204
+ *
205
+ * - `null` to invoke `doValueInvalid_` and not set a value.
206
+ *
207
+ * - `undefined` to set `newValue` as is.
208
+ */
209
+ export type FieldAngleValidator = FieldInputValidator<number>;
200
210
  //# sourceMappingURL=field_angle.d.ts.map
@@ -5,14 +5,12 @@
5
5
  */
6
6
  import './events/events_block_change.js';
7
7
  import { Field, FieldConfig, FieldValidator } from './field.js';
8
- import type { Sentinel } from './utils/sentinel.js';
9
- export type FieldCheckboxValidator = FieldValidator<boolean>;
8
+ type BoolString = 'TRUE' | 'FALSE';
9
+ type CheckboxBool = BoolString | boolean;
10
10
  /**
11
11
  * Class for a checkbox field.
12
- *
13
- * @alias Blockly.FieldCheckbox
14
12
  */
15
- export declare class FieldCheckbox extends Field<boolean> {
13
+ export declare class FieldCheckbox extends Field<CheckboxBool> {
16
14
  /** Default character for the checkmark. */
17
15
  static readonly CHECK_CHAR = "\u2713";
18
16
  private checkChar_;
@@ -25,22 +23,26 @@ export declare class FieldCheckbox extends Field<boolean> {
25
23
  * Mouse cursor style when over the hotspot that initiates editability.
26
24
  */
27
25
  CURSOR: string;
28
- value_: any;
29
26
  /**
30
- * @param opt_value The initial value of the field. Should either be 'TRUE',
27
+ * NOTE: The default value is set in `Field`, so maintain that value instead
28
+ * of overwriting it here or in the constructor.
29
+ */
30
+ value_: boolean | null;
31
+ /**
32
+ * @param value The initial value of the field. Should either be 'TRUE',
31
33
  * 'FALSE' or a boolean. Defaults to 'FALSE'. Also accepts
32
34
  * Field.SKIP_SETUP if you wish to skip setup (only used by subclasses
33
35
  * that want to handle configuration and setting the field value after
34
36
  * their own constructors have run).
35
- * @param opt_validator A function that is called to validate changes to the
37
+ * @param validator A function that is called to validate changes to the
36
38
  * field's value. Takes in a value ('TRUE' or 'FALSE') & returns a
37
39
  * validated value ('TRUE' or 'FALSE'), or null to abort the change.
38
- * @param opt_config A map of options used to configure the field.
40
+ * @param config A map of options used to configure the field.
39
41
  * See the [field creation documentation]{@link
40
42
  * https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/checkbox#creation}
41
43
  * for a list of properties this parameter supports.
42
44
  */
43
- constructor(opt_value?: string | boolean | Sentinel, opt_validator?: FieldCheckboxValidator, opt_config?: FieldCheckboxConfig);
45
+ constructor(value?: CheckboxBool | typeof Field.SKIP_SETUP, validator?: FieldCheckboxValidator, config?: FieldCheckboxConfig);
44
46
  /**
45
47
  * Configure the field based on the given map of options.
46
48
  *
@@ -74,29 +76,29 @@ export declare class FieldCheckbox extends Field<boolean> {
74
76
  /**
75
77
  * Ensure that the input value is valid ('TRUE' or 'FALSE').
76
78
  *
77
- * @param opt_newValue The input value.
79
+ * @param newValue The input value.
78
80
  * @returns A valid value ('TRUE' or 'FALSE), or null if invalid.
79
81
  */
80
- protected doClassValidation_(opt_newValue?: any): string | null;
82
+ protected doClassValidation_(newValue?: any): BoolString | null;
81
83
  /**
82
84
  * Update the value of the field, and update the checkElement.
83
85
  *
84
86
  * @param newValue The value to be saved. The default validator guarantees
85
87
  * that this is a either 'TRUE' or 'FALSE'.
86
88
  */
87
- protected doValueUpdate_(newValue: any): void;
89
+ protected doValueUpdate_(newValue: BoolString): void;
88
90
  /**
89
91
  * Get the value of this field, either 'TRUE' or 'FALSE'.
90
92
  *
91
93
  * @returns The value of this field.
92
94
  */
93
- getValue(): string;
95
+ getValue(): BoolString;
94
96
  /**
95
97
  * Get the boolean value of this field.
96
98
  *
97
99
  * @returns The boolean value of this field.
98
100
  */
99
- getValueBoolean(): boolean;
101
+ getValueBoolean(): boolean | null;
100
102
  /**
101
103
  * Get the text of this field. Used when the block is collapsed.
102
104
  *
@@ -135,4 +137,21 @@ export interface FieldCheckboxConfig extends FieldConfig {
135
137
  export interface FieldCheckboxFromJsonConfig extends FieldCheckboxConfig {
136
138
  checked?: boolean;
137
139
  }
140
+ /**
141
+ * A function that is called to validate changes to the field's value before
142
+ * they are set.
143
+ *
144
+ * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}
145
+ * @param newValue The value to be validated.
146
+ * @returns One of three instructions for setting the new value: `T`, `null`,
147
+ * or `undefined`.
148
+ *
149
+ * - `T` to set this function's returned value instead of `newValue`.
150
+ *
151
+ * - `null` to invoke `doValueInvalid_` and not set a value.
152
+ *
153
+ * - `undefined` to set `newValue` as is.
154
+ */
155
+ export type FieldCheckboxValidator = FieldValidator<CheckboxBool>;
156
+ export {};
138
157
  //# sourceMappingURL=field_checkbox.d.ts.map
@@ -5,12 +5,8 @@
5
5
  */
6
6
  import './events/events_block_change.js';
7
7
  import { Field, FieldConfig, FieldValidator } from './field.js';
8
- import type { Sentinel } from './utils/sentinel.js';
9
- export type FieldColourValidator = FieldValidator<string>;
10
8
  /**
11
9
  * Class for a colour input field.
12
- *
13
- * @alias Blockly.FieldColour
14
10
  */
15
11
  export declare class FieldColour extends Field<string> {
16
12
  /**
@@ -31,19 +27,15 @@ export declare class FieldColour extends Field<string> {
31
27
  */
32
28
  static COLUMNS: number;
33
29
  /** The field's colour picker element. */
34
- private picker_;
30
+ private picker;
35
31
  /** Index of the currently highlighted element. */
36
- private highlightedIndex_;
37
- /** Mouse click event data. */
38
- private onClickWrapper_;
39
- /** Mouse move event data. */
40
- private onMouseMoveWrapper_;
41
- /** Mouse enter event data. */
42
- private onMouseEnterWrapper_;
43
- /** Mouse leave event data. */
44
- private onMouseLeaveWrapper_;
45
- /** Key down event data. */
46
- private onKeyDownWrapper_;
32
+ private highlightedIndex;
33
+ /**
34
+ * Array holding info needed to unbind events.
35
+ * Used for disposing.
36
+ * Ex: [[node, name, func], [node, name, func]].
37
+ */
38
+ private boundEvents;
47
39
  /**
48
40
  * Serializable fields are saved by the serializer, non-serializable fields
49
41
  * are not. Editable fields should also be serializable.
@@ -58,35 +50,32 @@ export declare class FieldColour extends Field<string> {
58
50
  */
59
51
  protected isDirty_: boolean;
60
52
  /** Array of colours used by this field. If null, use the global list. */
61
- private colours_;
53
+ private colours;
62
54
  /**
63
55
  * Array of colour tooltips used by this field. If null, use the global
64
56
  * list.
65
57
  */
66
- private titles_;
58
+ private titles;
67
59
  /**
68
60
  * Number of colour columns used by this field. If 0, use the global
69
61
  * setting. By default use the global constants for columns.
70
62
  */
71
- private columns_;
72
- size_: any;
73
- clickTarget_: any;
74
- value_: any;
63
+ private columns;
75
64
  /**
76
- * @param opt_value The initial value of the field. Should be in '#rrggbb'
65
+ * @param value The initial value of the field. Should be in '#rrggbb'
77
66
  * format. Defaults to the first value in the default colour array. Also
78
67
  * accepts Field.SKIP_SETUP if you wish to skip setup (only used by
79
68
  * subclasses that want to handle configuration and setting the field
80
69
  * value after their own constructors have run).
81
- * @param opt_validator A function that is called to validate changes to the
70
+ * @param validator A function that is called to validate changes to the
82
71
  * field's value. Takes in a colour string & returns a validated colour
83
- * string ('#rrggbb' format), or null to abort the change.Blockly.
84
- * @param opt_config A map of options used to configure the field.
72
+ * string ('#rrggbb' format), or null to abort the change.
73
+ * @param config A map of options used to configure the field.
85
74
  * See the [field creation documentation]{@link
86
75
  * https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/colour}
87
76
  * for a list of properties this parameter supports.
88
77
  */
89
- constructor(opt_value?: string | Sentinel, opt_validator?: FieldColourValidator, opt_config?: FieldColourConfig);
78
+ constructor(value?: string | typeof Field.SKIP_SETUP, validator?: FieldColourValidator, config?: FieldColourConfig);
90
79
  /**
91
80
  * Configure the field based on the given map of options.
92
81
  *
@@ -99,21 +88,26 @@ export declare class FieldColour extends Field<string> {
99
88
  * @internal
100
89
  */
101
90
  initView(): void;
91
+ /**
92
+ * Updates text field to match the colour/style of the block.
93
+ *
94
+ * @internal
95
+ */
102
96
  applyColour(): void;
103
97
  /**
104
98
  * Ensure that the input value is a valid colour.
105
99
  *
106
- * @param opt_newValue The input value.
100
+ * @param newValue The input value.
107
101
  * @returns A valid colour, or null if invalid.
108
102
  */
109
- protected doClassValidation_(opt_newValue?: any): string | null;
103
+ protected doClassValidation_(newValue?: any): string | null;
110
104
  /**
111
105
  * Update the value of this colour field, and update the displayed colour.
112
106
  *
113
107
  * @param newValue The value to be saved. The default validator guarantees
114
108
  * that this is a colour in '#rrggbb' format.
115
109
  */
116
- protected doValueUpdate_(newValue: any): void;
110
+ protected doValueUpdate_(newValue: string): void;
117
111
  /**
118
112
  * Get the text for this field. Used when the block is collapsed.
119
113
  *
@@ -125,11 +119,11 @@ export declare class FieldColour extends Field<string> {
125
119
  *
126
120
  * @param colours Array of colours for this block, or null to use default
127
121
  * (FieldColour.COLOURS).
128
- * @param opt_titles Optional array of colour tooltips, or null to use default
122
+ * @param titles Optional array of colour tooltips, or null to use default
129
123
  * (FieldColour.TITLES).
130
124
  * @returns Returns itself (for method chaining).
131
125
  */
132
- setColours(colours: string[], opt_titles?: string[]): FieldColour;
126
+ setColours(colours: string[], titles?: string[]): FieldColour;
133
127
  /**
134
128
  * Set a custom grid size for this field.
135
129
  *
@@ -145,51 +139,51 @@ export declare class FieldColour extends Field<string> {
145
139
  *
146
140
  * @param e Mouse event.
147
141
  */
148
- private onClick_;
142
+ private onClick;
149
143
  /**
150
144
  * Handle a key down event. Navigate around the grid with the
151
145
  * arrow keys. Enter selects the highlighted colour.
152
146
  *
153
147
  * @param e Keyboard event.
154
148
  */
155
- private onKeyDown_;
149
+ private onKeyDown;
156
150
  /**
157
151
  * Move the currently highlighted position by dx and dy.
158
152
  *
159
- * @param dx Change of x
160
- * @param dy Change of y
153
+ * @param dx Change of x.
154
+ * @param dy Change of y.
161
155
  */
162
- private moveHighlightBy_;
156
+ private moveHighlightBy;
163
157
  /**
164
158
  * Handle a mouse move event. Highlight the hovered colour.
165
159
  *
166
160
  * @param e Mouse event.
167
161
  */
168
- private onMouseMove_;
162
+ private onMouseMove;
169
163
  /** Handle a mouse enter event. Focus the picker. */
170
- private onMouseEnter_;
164
+ private onMouseEnter;
171
165
  /**
172
166
  * Handle a mouse leave event. Blur the picker and unhighlight
173
167
  * the currently highlighted colour.
174
168
  */
175
- private onMouseLeave_;
169
+ private onMouseLeave;
176
170
  /**
177
171
  * Returns the currently highlighted item (if any).
178
172
  *
179
173
  * @returns Highlighted item (null if none).
180
174
  */
181
- private getHighlighted_;
175
+ private getHighlighted;
182
176
  /**
183
177
  * Update the currently highlighted cell.
184
178
  *
185
- * @param cell the new cell to highlight
186
- * @param index the index of the new cell
179
+ * @param cell The new cell to highlight.
180
+ * @param index The index of the new cell.
187
181
  */
188
- private setHighlightedCell_;
182
+ private setHighlightedCell;
189
183
  /** Create a colour picker dropdown editor. */
190
- private dropdownCreate_;
184
+ private dropdownCreate;
191
185
  /** Disposes of events and DOM-references belonging to the colour editor. */
192
- private dropdownDispose_;
186
+ private dropdownDispose;
193
187
  /**
194
188
  * Construct a FieldColour from a JSON arg object.
195
189
  *
@@ -214,4 +208,20 @@ export interface FieldColourConfig extends FieldConfig {
214
208
  export interface FieldColourFromJsonConfig extends FieldColourConfig {
215
209
  colour?: string;
216
210
  }
211
+ /**
212
+ * A function that is called to validate changes to the field's value before
213
+ * they are set.
214
+ *
215
+ * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}
216
+ * @param newValue The value to be validated.
217
+ * @returns One of three instructions for setting the new value: `T`, `null`,
218
+ * or `undefined`.
219
+ *
220
+ * - `T` to set this function's returned value instead of `newValue`.
221
+ *
222
+ * - `null` to invoke `doValueInvalid_` and not set a value.
223
+ *
224
+ * - `undefined` to set `newValue` as is.
225
+ */
226
+ export type FieldColourValidator = FieldValidator<string>;
217
227
  //# sourceMappingURL=field_colour.d.ts.map
@@ -6,12 +6,8 @@
6
6
  import { Field, FieldConfig, FieldValidator } from './field.js';
7
7
  import { Menu } from './menu.js';
8
8
  import { MenuItem } from './menuitem.js';
9
- import type { Sentinel } from './utils/sentinel.js';
10
- export type FieldDropdownValidator = FieldValidator<string>;
11
9
  /**
12
10
  * Class for an editable dropdown field.
13
- *
14
- * @alias Blockly.FieldDropdown
15
11
  */
16
12
  export declare class FieldDropdown extends Field<string> {
17
13
  /** Horizontal distance that a checkmark overhangs the dropdown. */
@@ -64,18 +60,18 @@ export declare class FieldDropdown extends Field<string> {
64
60
  * if you wish to skip setup (only used by subclasses that want to handle
65
61
  * configuration and setting the field value after their own constructors
66
62
  * have run).
67
- * @param opt_validator A function that is called to validate changes to the
63
+ * @param validator A function that is called to validate changes to the
68
64
  * field's value. Takes in a language-neutral dropdown option & returns a
69
65
  * validated language-neutral dropdown option, or null to abort the
70
66
  * change.
71
- * @param opt_config A map of options used to configure the field.
67
+ * @param config A map of options used to configure the field.
72
68
  * See the [field creation documentation]{@link
73
69
  * https://developers.google.com/blockly/guides/create-custom-blocks/fields/built-in-fields/dropdown#creation}
74
70
  * for a list of properties this parameter supports.
75
71
  * @throws {TypeError} If `menuGenerator` options are incorrectly structured.
76
72
  */
77
- constructor(menuGenerator: MenuGenerator, opt_validator?: FieldDropdownValidator, opt_config?: FieldConfig);
78
- constructor(menuGenerator: Sentinel);
73
+ constructor(menuGenerator: MenuGenerator, validator?: FieldDropdownValidator, config?: FieldDropdownConfig);
74
+ constructor(menuGenerator: typeof Field.SKIP_SETUP);
79
75
  /**
80
76
  * Sets the field's value based on the given XML element. Should only be
81
77
  * called by Blockly.Xml.
@@ -110,16 +106,16 @@ export declare class FieldDropdown extends Field<string> {
110
106
  /**
111
107
  * Create a dropdown menu under the text.
112
108
  *
113
- * @param opt_e Optional mouse event that triggered the field to open, or
109
+ * @param e Optional mouse event that triggered the field to open, or
114
110
  * undefined if triggered programmatically.
115
111
  */
116
- protected showEditor_(opt_e?: MouseEvent): void;
112
+ protected showEditor_(e?: MouseEvent): void;
117
113
  /** Create the dropdown editor. */
118
114
  private dropdownCreate_;
119
115
  /**
120
116
  * Disposes of events and DOM-references belonging to the dropdown editor.
121
117
  */
122
- private dropdownDispose_;
118
+ protected dropdownDispose_(): void;
123
119
  /**
124
120
  * Handle an action in the dropdown menu.
125
121
  *
@@ -141,27 +137,27 @@ export declare class FieldDropdown extends Field<string> {
141
137
  /**
142
138
  * Return a list of the options for this dropdown.
143
139
  *
144
- * @param opt_useCache For dynamic options, whether or not to use the cached
140
+ * @param useCache For dynamic options, whether or not to use the cached
145
141
  * options or to re-generate them.
146
142
  * @returns A non-empty array of option tuples:
147
143
  * (human-readable text or image, language-neutral name).
148
144
  * @throws {TypeError} If generated options are incorrectly structured.
149
145
  */
150
- getOptions(opt_useCache?: boolean): MenuOption[];
146
+ getOptions(useCache?: boolean): MenuOption[];
151
147
  /**
152
148
  * Ensure that the input value is a valid language-neutral option.
153
149
  *
154
- * @param opt_newValue The input value.
150
+ * @param newValue The input value.
155
151
  * @returns A valid language-neutral option, or null if invalid.
156
152
  */
157
- protected doClassValidation_(opt_newValue?: MenuOption[1]): string | null;
153
+ protected doClassValidation_(newValue?: string): string | null;
158
154
  /**
159
155
  * Update the value of this dropdown field.
160
156
  *
161
157
  * @param newValue The value to be saved. The default validator guarantees
162
158
  * that this is one of the valid dropdown options.
163
159
  */
164
- protected doValueUpdate_(newValue: MenuOption[1]): void;
160
+ protected doValueUpdate_(newValue: string): void;
165
161
  /**
166
162
  * Updates the dropdown arrow to match the colour/style of the block.
167
163
  *
@@ -188,8 +184,8 @@ export declare class FieldDropdown extends Field<string> {
188
184
  private positionSVGArrow_;
189
185
  /**
190
186
  * Use the `getText_` developer hook to override the field's text
191
- * representation. Get the selected option text. If the selected option is an
192
- * image we return the image alt text.
187
+ * representation. Get the selected option text. If the selected option is
188
+ * an image we return the image alt text.
193
189
  *
194
190
  * @returns Selected option text.
195
191
  */
@@ -229,10 +225,30 @@ export type MenuGeneratorFunction = (this: FieldDropdown) => MenuOption[];
229
225
  * menu options for FieldDropdown or its descendants.
230
226
  */
231
227
  export type MenuGenerator = MenuOption[] | MenuGeneratorFunction;
228
+ /**
229
+ * Config options for the dropdown field.
230
+ */
231
+ export type FieldDropdownConfig = FieldConfig;
232
232
  /**
233
233
  * fromJson config for the dropdown field.
234
234
  */
235
- export interface FieldDropdownFromJsonConfig extends FieldConfig {
235
+ export interface FieldDropdownFromJsonConfig extends FieldDropdownConfig {
236
236
  options?: MenuOption[];
237
237
  }
238
+ /**
239
+ * A function that is called to validate changes to the field's value before
240
+ * they are set.
241
+ *
242
+ * @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}
243
+ * @param newValue The value to be validated.
244
+ * @returns One of three instructions for setting the new value: `T`, `null`,
245
+ * or `undefined`.
246
+ *
247
+ * - `T` to set this function's returned value instead of `newValue`.
248
+ *
249
+ * - `null` to invoke `doValueInvalid_` and not set a value.
250
+ *
251
+ * - `undefined` to set `newValue` as is.
252
+ */
253
+ export type FieldDropdownValidator = FieldValidator<string>;
238
254
  //# sourceMappingURL=field_dropdown.d.ts.map