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.
- package/blockly.min.js +1615 -1509
- package/blockly_compressed.js +1249 -1136
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +166 -173
- package/blocks_compressed.js.map +1 -1
- package/core/any_aliases.d.ts +5 -0
- package/core/block.d.ts +49 -17
- package/core/block_animations.d.ts +0 -4
- package/core/block_dragger.d.ts +1 -6
- package/core/block_svg.d.ts +58 -8
- package/core/blockly.d.ts +27 -58
- package/core/blockly_options.d.ts +0 -2
- package/core/blocks.d.ts +0 -2
- package/core/browser_events.d.ts +0 -9
- package/core/bubble.d.ts +0 -2
- package/core/bubble_dragger.d.ts +0 -2
- package/core/bump_objects.d.ts +0 -3
- package/core/clipboard.d.ts +0 -3
- package/core/comment.d.ts +6 -10
- package/core/common.d.ts +0 -12
- package/core/component_manager.d.ts +0 -2
- package/core/connection.d.ts +19 -6
- package/core/connection_checker.d.ts +1 -3
- package/core/connection_db.d.ts +0 -2
- package/core/connection_type.d.ts +0 -2
- package/core/constants.d.ts +0 -4
- package/core/contextmenu.d.ts +0 -11
- package/core/contextmenu_items.d.ts +0 -27
- package/core/contextmenu_registry.d.ts +0 -2
- package/core/css.d.ts +0 -2
- package/core/delete_area.d.ts +0 -2
- package/core/dialog.d.ts +0 -6
- package/core/drag_target.d.ts +0 -2
- package/core/events/events.d.ts +2 -22
- package/core/events/events_abstract.d.ts +7 -3
- package/core/events/events_block_base.d.ts +2 -3
- package/core/events/events_block_change.d.ts +9 -3
- package/core/events/events_block_create.d.ts +6 -4
- package/core/events/events_block_delete.d.ts +7 -4
- package/core/events/events_block_drag.d.ts +7 -3
- package/core/events/events_block_move.d.ts +20 -3
- package/core/events/events_bubble_open.d.ts +3 -2
- package/core/events/events_click.d.ts +6 -3
- package/core/events/events_comment_base.d.ts +1 -2
- package/core/events/events_comment_change.d.ts +3 -3
- package/core/events/events_comment_create.d.ts +2 -3
- package/core/events/events_comment_delete.d.ts +2 -3
- package/core/events/events_comment_move.d.ts +4 -4
- package/core/events/events_marker_move.d.ts +10 -3
- package/core/events/events_selected.d.ts +6 -2
- package/core/events/events_theme_change.d.ts +2 -3
- package/core/events/events_toolbox_item_select.d.ts +3 -3
- package/core/events/events_trashcan_open.d.ts +5 -3
- package/core/events/events_ui.d.ts +0 -1
- package/core/events/events_ui_base.d.ts +0 -2
- package/core/events/events_var_base.d.ts +1 -2
- package/core/events/events_var_create.d.ts +3 -3
- package/core/events/events_var_delete.d.ts +4 -2
- package/core/events/events_var_rename.d.ts +4 -2
- package/core/events/events_viewport.d.ts +13 -2
- package/core/events/utils.d.ts +0 -89
- package/core/events/workspace_events.d.ts +2 -6
- package/core/extensions.d.ts +0 -8
- package/core/field.d.ts +55 -21
- package/core/field_angle.d.ts +61 -51
- package/core/field_checkbox.d.ts +34 -15
- package/core/field_colour.d.ts +56 -46
- package/core/field_dropdown.d.ts +35 -19
- package/core/field_image.d.ts +10 -14
- package/core/field_input.d.ts +39 -25
- package/core/field_label.d.ts +7 -10
- package/core/field_label_serializable.d.ts +4 -6
- package/core/field_multilineinput.d.ts +36 -14
- package/core/field_number.d.ts +27 -19
- package/core/field_registry.d.ts +0 -3
- package/core/field_textinput.d.ts +36 -8
- package/core/field_variable.d.ts +30 -18
- package/core/flyout_base.d.ts +5 -6
- package/core/flyout_button.d.ts +2 -2
- package/core/flyout_horizontal.d.ts +0 -2
- package/core/flyout_metrics_manager.d.ts +0 -2
- package/core/flyout_vertical.d.ts +0 -2
- package/core/generator.d.ts +0 -1
- package/core/gesture.d.ts +5 -18
- package/core/grid.d.ts +0 -2
- package/core/icon.d.ts +0 -2
- package/core/inject.d.ts +0 -1
- package/core/input.d.ts +0 -3
- package/core/input_types.d.ts +0 -2
- package/core/insertion_marker_manager.d.ts +6 -6
- package/core/interfaces/i_ast_node_location.d.ts +0 -2
- package/core/interfaces/i_ast_node_location_svg.d.ts +0 -2
- package/core/interfaces/i_ast_node_location_with_block.d.ts +0 -2
- package/core/interfaces/i_autohideable.d.ts +0 -2
- package/core/interfaces/i_block_dragger.d.ts +0 -2
- package/core/interfaces/i_bounded_element.d.ts +0 -2
- package/core/interfaces/i_bubble.d.ts +0 -2
- package/core/interfaces/i_collapsible_toolbox_item.d.ts +0 -2
- package/core/interfaces/i_component.d.ts +0 -2
- package/core/interfaces/i_connection_checker.d.ts +0 -2
- package/core/interfaces/i_contextmenu.d.ts +0 -1
- package/core/interfaces/i_copyable.d.ts +3 -2
- package/core/interfaces/i_deletable.d.ts +0 -2
- package/core/interfaces/i_delete_area.d.ts +0 -2
- package/core/interfaces/i_drag_target.d.ts +0 -2
- package/core/interfaces/i_draggable.d.ts +0 -2
- package/core/interfaces/i_flyout.d.ts +0 -2
- package/core/interfaces/i_keyboard_accessible.d.ts +0 -2
- package/core/interfaces/i_legacy_procedure_blocks.d.ts +34 -0
- package/core/interfaces/i_metrics_manager.d.ts +8 -8
- package/core/interfaces/i_movable.d.ts +0 -2
- package/core/interfaces/i_positionable.d.ts +0 -2
- package/core/interfaces/i_procedure_block.d.ts +3 -0
- package/core/interfaces/i_procedure_model.d.ts +0 -5
- package/core/interfaces/i_registrable.d.ts +0 -2
- package/core/interfaces/i_selectable.d.ts +0 -2
- package/core/interfaces/i_selectable_toolbox_item.d.ts +4 -2
- package/core/interfaces/i_serializer.d.ts +0 -2
- package/core/interfaces/i_styleable.d.ts +0 -2
- package/core/interfaces/i_toolbox.d.ts +0 -2
- package/core/interfaces/i_toolbox_item.d.ts +0 -2
- package/core/interfaces/i_variable_backed_parameter_model.d.ts +17 -0
- package/core/internal_constants.d.ts +0 -5
- package/core/keyboard_nav/ast_node.d.ts +0 -3
- package/core/keyboard_nav/basic_cursor.d.ts +0 -3
- package/core/keyboard_nav/cursor.d.ts +0 -3
- package/core/keyboard_nav/marker.d.ts +0 -2
- package/core/keyboard_nav/tab_navigate_cursor.d.ts +0 -2
- package/core/marker_manager.d.ts +0 -2
- package/core/menu.d.ts +0 -2
- package/core/menuitem.d.ts +0 -2
- package/core/metrics_manager.d.ts +8 -8
- package/core/mutator.d.ts +0 -2
- package/core/names.d.ts +0 -3
- package/core/{procedures/observable_procedure_map.d.ts → observable_procedure_map.d.ts} +4 -5
- package/core/options.d.ts +0 -2
- package/core/positionable_helpers.d.ts +0 -7
- package/core/procedures.d.ts +7 -28
- package/core/registry.d.ts +0 -11
- package/core/render_management.d.ts +15 -0
- package/core/rendered_connection.d.ts +22 -9
- package/core/renderers/common/block_rendering.d.ts +0 -3
- package/core/renderers/common/constants.d.ts +6 -51
- package/core/renderers/common/debug.d.ts +0 -3
- package/core/renderers/common/debugger.d.ts +9 -23
- package/core/renderers/common/drawer.d.ts +0 -5
- package/core/renderers/common/i_path_object.d.ts +0 -17
- package/core/renderers/common/info.d.ts +2 -12
- package/core/renderers/common/marker_svg.d.ts +2 -4
- package/core/renderers/common/path_object.d.ts +0 -24
- package/core/renderers/common/renderer.d.ts +5 -20
- package/core/renderers/geras/constants.d.ts +0 -5
- package/core/renderers/geras/drawer.d.ts +2 -4
- package/core/renderers/geras/highlight_constants.d.ts +6 -17
- package/core/renderers/geras/highlighter.d.ts +0 -13
- package/core/renderers/geras/info.d.ts +2 -5
- package/core/renderers/geras/measurables/inline_input.d.ts +0 -3
- package/core/renderers/geras/measurables/statement_input.d.ts +0 -3
- package/core/renderers/geras/path_object.d.ts +0 -8
- package/core/renderers/geras/renderer.d.ts +5 -7
- package/core/renderers/measurables/base.d.ts +0 -3
- package/core/renderers/measurables/bottom_row.d.ts +0 -9
- package/core/renderers/measurables/connection.d.ts +0 -3
- package/core/renderers/measurables/external_value_input.d.ts +0 -3
- package/core/renderers/measurables/field.d.ts +0 -3
- package/core/renderers/measurables/hat.d.ts +0 -3
- package/core/renderers/measurables/icon.d.ts +2 -5
- package/core/renderers/measurables/in_row_spacer.d.ts +0 -3
- package/core/renderers/measurables/inline_input.d.ts +1 -4
- package/core/renderers/measurables/input_connection.d.ts +1 -4
- package/core/renderers/measurables/input_row.d.ts +0 -7
- package/core/renderers/measurables/jagged_edge.d.ts +2 -5
- package/core/renderers/measurables/next_connection.d.ts +0 -3
- package/core/renderers/measurables/output_connection.d.ts +0 -3
- package/core/renderers/measurables/previous_connection.d.ts +0 -3
- package/core/renderers/measurables/round_corner.d.ts +0 -3
- package/core/renderers/measurables/row.d.ts +0 -39
- package/core/renderers/measurables/spacer_row.d.ts +0 -3
- package/core/renderers/measurables/square_corner.d.ts +0 -3
- package/core/renderers/measurables/statement_input.d.ts +0 -3
- package/core/renderers/measurables/top_row.d.ts +0 -6
- package/core/renderers/measurables/types.d.ts +0 -31
- package/core/renderers/minimalist/constants.d.ts +2 -4
- package/core/renderers/minimalist/drawer.d.ts +0 -3
- package/core/renderers/minimalist/info.d.ts +0 -4
- package/core/renderers/minimalist/renderer.d.ts +0 -3
- package/core/renderers/thrasos/info.d.ts +0 -4
- package/core/renderers/thrasos/renderer.d.ts +3 -3
- package/core/renderers/zelos/constants.d.ts +3 -17
- package/core/renderers/zelos/drawer.d.ts +0 -3
- package/core/renderers/zelos/info.d.ts +0 -4
- package/core/renderers/zelos/marker_svg.d.ts +0 -2
- package/core/renderers/zelos/measurables/bottom_row.d.ts +0 -3
- package/core/renderers/zelos/measurables/inputs.d.ts +0 -3
- package/core/renderers/zelos/measurables/row_elements.d.ts +0 -3
- package/core/renderers/zelos/measurables/top_row.d.ts +0 -3
- package/core/renderers/zelos/path_object.d.ts +0 -9
- package/core/renderers/zelos/renderer.d.ts +3 -5
- package/core/scrollbar.d.ts +0 -2
- package/core/scrollbar_pair.d.ts +0 -2
- package/core/serialization/blocks.d.ts +3 -9
- package/core/serialization/exceptions.d.ts +0 -8
- package/core/serialization/priorities.d.ts +0 -4
- package/core/serialization/procedures.d.ts +0 -7
- package/core/serialization/registry.d.ts +0 -2
- package/core/serialization/variables.d.ts +0 -4
- package/core/serialization/workspaces.d.ts +0 -2
- package/core/shortcut_items.d.ts +0 -17
- package/core/shortcut_registry.d.ts +0 -2
- package/core/sprites.d.ts +0 -2
- package/core/theme/classic.d.ts +0 -2
- package/core/theme/zelos.d.ts +0 -2
- package/core/theme.d.ts +0 -2
- package/core/theme_manager.d.ts +3 -6
- package/core/toolbox/category.d.ts +5 -7
- package/core/toolbox/collapsible_category.d.ts +0 -4
- package/core/toolbox/separator.d.ts +0 -2
- package/core/toolbox/toolbox.d.ts +2 -5
- package/core/toolbox/toolbox_item.d.ts +0 -2
- package/core/tooltip.d.ts +0 -29
- package/core/touch.d.ts +0 -13
- package/core/trashcan.d.ts +0 -2
- package/core/utils/aria.d.ts +0 -6
- package/core/utils/array.d.ts +0 -1
- package/core/utils/colour.d.ts +0 -12
- package/core/utils/coordinate.d.ts +0 -2
- package/core/utils/deprecation.d.ts +0 -1
- package/core/utils/dom.d.ts +0 -25
- package/core/utils/idgenerator.d.ts +0 -2
- package/core/utils/keycodes.d.ts +0 -2
- package/core/utils/math.d.ts +0 -3
- package/core/utils/metrics.d.ts +0 -1
- package/core/utils/object.d.ts +0 -4
- package/core/utils/parsing.d.ts +0 -4
- package/core/utils/rect.d.ts +0 -2
- package/core/utils/size.d.ts +0 -2
- package/core/utils/string.d.ts +0 -6
- package/core/utils/style.d.ts +0 -8
- package/core/utils/svg.d.ts +0 -2
- package/core/utils/svg_math.d.ts +0 -6
- package/core/utils/svg_paths.d.ts +0 -8
- package/core/utils/toolbox.d.ts +2 -35
- package/core/utils/useragent.d.ts +0 -8
- package/core/utils/xml.d.ts +9 -8
- package/core/utils.d.ts +0 -12
- package/core/variable_map.d.ts +1 -3
- package/core/variable_model.d.ts +0 -1
- package/core/variables.d.ts +13 -17
- package/core/variables_dynamic.d.ts +0 -4
- package/core/warning.d.ts +0 -2
- package/core/widgetdiv.d.ts +0 -10
- package/core/workspace.d.ts +3 -3
- package/core/workspace_audio.d.ts +0 -2
- package/core/workspace_comment.d.ts +1 -3
- package/core/workspace_comment_svg.d.ts +1 -3
- package/core/workspace_dragger.d.ts +0 -2
- package/core/workspace_svg.d.ts +4 -7
- package/core/xml.d.ts +1 -13
- package/core/zoom_controls.d.ts +4 -15
- package/dart_compressed.js +199 -199
- package/dart_compressed.js.map +1 -1
- package/javascript_compressed.js +168 -168
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +211 -211
- package/lua_compressed.js.map +1 -1
- package/msg/bn.js +2 -2
- package/msg/bs.js +7 -7
- package/msg/de.js +1 -1
- package/msg/fi.js +1 -1
- package/msg/fr.js +3 -3
- package/msg/ia.js +5 -5
- package/msg/kn.js +5 -5
- package/msg/ko.js +1 -1
- package/msg/lb.js +22 -22
- package/msg/sd.js +9 -9
- package/msg/skr-arab.js +2 -2
- package/msg/sl.js +18 -18
- package/msg/sw.js +1 -1
- package/msg/zh-hans.js +6 -6
- package/msg/zh-hant.js +2 -2
- package/package.json +9 -9
- package/php_compressed.js +185 -185
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +138 -138
- package/python_compressed.js.map +1 -1
- package/core/events/events_procedure_base.d.ts +0 -26
- package/core/events/events_procedure_change_return.d.ts +0 -40
- package/core/events/events_procedure_create.d.ts +0 -34
- package/core/events/events_procedure_delete.d.ts +0 -32
- package/core/events/events_procedure_enable.d.ts +0 -34
- package/core/events/events_procedure_parameter_base.d.ts +0 -26
- package/core/events/events_procedure_parameter_create.d.ts +0 -42
- package/core/events/events_procedure_parameter_delete.d.ts +0 -41
- package/core/events/events_procedure_parameter_rename.d.ts +0 -36
- package/core/events/events_procedure_rename.d.ts +0 -35
- package/core/procedures/observable_parameter_model.d.ts +0 -62
- package/core/procedures/observable_procedure_model.d.ts +0 -75
- package/core/procedures/update_procedures.d.ts +0 -13
- package/core/utils/sentinel.d.ts +0 -13
package/core/field_angle.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
40
|
-
*
|
|
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
|
|
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
|
|
44
|
+
private clockwise;
|
|
48
45
|
/**
|
|
49
46
|
* The offset of zero degrees (and all other angles).
|
|
50
47
|
*/
|
|
51
|
-
private
|
|
48
|
+
private offset;
|
|
52
49
|
/**
|
|
53
50
|
* The maximum angle to allow before wrapping.
|
|
54
51
|
*/
|
|
55
|
-
private
|
|
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
|
|
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
|
-
*
|
|
76
|
-
*
|
|
58
|
+
* Array holding info needed to unbind events.
|
|
59
|
+
* Used for disposing.
|
|
60
|
+
* Ex: [[node, name, func], [node, name, func]].
|
|
77
61
|
*/
|
|
78
|
-
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
111
|
+
private dropdownDispose;
|
|
118
112
|
/** Hide the editor. */
|
|
119
|
-
private
|
|
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
|
|
127
|
+
private displayMouseOrKeyboardValue;
|
|
134
128
|
/** Redraw the graph with the current angle. */
|
|
135
|
-
private
|
|
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:
|
|
135
|
+
protected onHtmlInputKeyDown_(e: KeyboardEvent): void;
|
|
142
136
|
/**
|
|
143
137
|
* Ensure that the input value is a valid angle.
|
|
144
138
|
*
|
|
145
|
-
* @param
|
|
139
|
+
* @param newValue The input value.
|
|
146
140
|
* @returns A valid angle, or null if invalid.
|
|
147
141
|
*/
|
|
148
|
-
protected doClassValidation_(
|
|
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
|
|
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
|
package/core/field_checkbox.d.ts
CHANGED
|
@@ -5,14 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import './events/events_block_change.js';
|
|
7
7
|
import { Field, FieldConfig, FieldValidator } from './field.js';
|
|
8
|
-
|
|
9
|
-
|
|
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<
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
79
|
+
* @param newValue The input value.
|
|
78
80
|
* @returns A valid value ('TRUE' or 'FALSE), or null if invalid.
|
|
79
81
|
*/
|
|
80
|
-
protected doClassValidation_(
|
|
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:
|
|
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():
|
|
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
|
package/core/field_colour.d.ts
CHANGED
|
@@ -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
|
|
30
|
+
private picker;
|
|
35
31
|
/** Index of the currently highlighted element. */
|
|
36
|
-
private
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
private
|
|
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
|
|
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
|
|
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
|
|
72
|
-
size_: any;
|
|
73
|
-
clickTarget_: any;
|
|
74
|
-
value_: any;
|
|
63
|
+
private columns;
|
|
75
64
|
/**
|
|
76
|
-
* @param
|
|
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
|
|
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.
|
|
84
|
-
* @param
|
|
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(
|
|
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
|
|
100
|
+
* @param newValue The input value.
|
|
107
101
|
* @returns A valid colour, or null if invalid.
|
|
108
102
|
*/
|
|
109
|
-
protected doClassValidation_(
|
|
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:
|
|
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
|
|
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[],
|
|
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
|
|
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
|
|
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
|
|
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
|
|
162
|
+
private onMouseMove;
|
|
169
163
|
/** Handle a mouse enter event. Focus the picker. */
|
|
170
|
-
private
|
|
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
|
|
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
|
|
175
|
+
private getHighlighted;
|
|
182
176
|
/**
|
|
183
177
|
* Update the currently highlighted cell.
|
|
184
178
|
*
|
|
185
|
-
* @param cell
|
|
186
|
-
* @param index
|
|
179
|
+
* @param cell The new cell to highlight.
|
|
180
|
+
* @param index The index of the new cell.
|
|
187
181
|
*/
|
|
188
|
-
private
|
|
182
|
+
private setHighlightedCell;
|
|
189
183
|
/** Create a colour picker dropdown editor. */
|
|
190
|
-
private
|
|
184
|
+
private dropdownCreate;
|
|
191
185
|
/** Disposes of events and DOM-references belonging to the colour editor. */
|
|
192
|
-
private
|
|
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
|
package/core/field_dropdown.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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,
|
|
78
|
-
constructor(menuGenerator:
|
|
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
|
|
109
|
+
* @param e Optional mouse event that triggered the field to open, or
|
|
114
110
|
* undefined if triggered programmatically.
|
|
115
111
|
*/
|
|
116
|
-
protected showEditor_(
|
|
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
|
-
|
|
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
|
|
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(
|
|
146
|
+
getOptions(useCache?: boolean): MenuOption[];
|
|
151
147
|
/**
|
|
152
148
|
* Ensure that the input value is a valid language-neutral option.
|
|
153
149
|
*
|
|
154
|
-
* @param
|
|
150
|
+
* @param newValue The input value.
|
|
155
151
|
* @returns A valid language-neutral option, or null if invalid.
|
|
156
152
|
*/
|
|
157
|
-
protected doClassValidation_(
|
|
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:
|
|
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.
|
|
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
|
|
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
|