mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
fix: export Field-related types from Blockly (#6877)
* chore: re-exported Field config types from Blockly * mark `@internal` types, export field error, and add validator comments
This commit is contained in:
committed by
GitHub
parent
3a7ac3be1b
commit
9e5bfc243e
@@ -20,8 +20,6 @@ import * as fieldRegistry from './field_registry.js';
|
||||
import * as parsing from './utils/parsing.js';
|
||||
import type {Sentinel} from './utils/sentinel.js';
|
||||
|
||||
export type FieldTextInputValidator = FieldInputValidator<string>;
|
||||
|
||||
/**
|
||||
* Class for an editable text field.
|
||||
*/
|
||||
@@ -42,7 +40,7 @@ export class FieldTextInput extends FieldInput<string> {
|
||||
*/
|
||||
constructor(
|
||||
opt_value?: string|Sentinel, opt_validator?: FieldTextInputValidator|null,
|
||||
opt_config?: FieldInputConfig) {
|
||||
opt_config?: FieldTextInputConfig) {
|
||||
super(opt_value, opt_validator, opt_config);
|
||||
}
|
||||
|
||||
@@ -81,11 +79,31 @@ fieldRegistry.register('field_input', FieldTextInput);
|
||||
|
||||
FieldTextInput.prototype.DEFAULT_VALUE = '';
|
||||
|
||||
/**
|
||||
* Config options for the text input field.
|
||||
*/
|
||||
export type FieldTextInputConfig = FieldInputConfig;
|
||||
|
||||
/**
|
||||
* fromJson config options for the text input field.
|
||||
*/
|
||||
export interface FieldTextInputFromJsonConfig extends FieldInputConfig {
|
||||
export interface FieldTextInputFromJsonConfig extends FieldTextInputConfig {
|
||||
text?: string;
|
||||
}
|
||||
|
||||
export {FieldInputConfig as FieldTextInputConfig};
|
||||
/**
|
||||
* A function that is called to validate changes to the field's value before
|
||||
* they are set.
|
||||
*
|
||||
* @see {@link https://developers.google.com/blockly/guides/create-custom-blocks/fields/validators#return_values}
|
||||
* @param newValue The value to be validated.
|
||||
* @returns One of three instructions for setting the new value: `T`, `null`,
|
||||
* or `undefined`.
|
||||
*
|
||||
* - `T` to set this function's returned value instead of `newValue`.
|
||||
*
|
||||
* - `null` to invoke `doValueInvalid_` and not set a value.
|
||||
*
|
||||
* - `undefined` to set `newValue` as is.
|
||||
*/
|
||||
export type FieldTextInputValidator = FieldInputValidator<string>;
|
||||
|
||||
Reference in New Issue
Block a user