mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
* chore(deps): Add pretter-plugin-organize-imports * chore: Remove insignificant blank lines in import sections Since prettier-plugin-organize-imports sorts imports within sections separated by blank lines, but preserves the section divisions, remove any blank lines that are not dividing imports into meaningful sections. Do not remove blank lines separating side-effect-only imports from main imports. * chore: Remove unneded eslint-disable directives * chore: Organise imports
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
// Former goog.module ID: Blockly.blockRendering.InputRow
|
|
|
|
import type {ConstantProvider} from '../common/constants.js';
|
|
import {ExternalValueInput} from './external_value_input.js';
|
|
import {InputConnection} from './input_connection.js';
|
|
import {Row} from './row.js';
|
|
import {StatementInput} from './statement_input.js';
|
|
import {Types} from './types.js';
|
|
|
|
/**
|
|
* An object containing information about a row that holds one or more inputs.
|
|
*/
|
|
export class InputRow extends Row {
|
|
/**
|
|
* The total width of all blocks connected to this row.
|
|
*/
|
|
connectedBlockWidths = 0;
|
|
|
|
/**
|
|
* @param constants The rendering constants provider.
|
|
*/
|
|
constructor(constants: ConstantProvider) {
|
|
super(constants);
|
|
this.type |= Types.INPUT_ROW;
|
|
}
|
|
|
|
/**
|
|
* Inspect all subcomponents and populate all size properties on the row.
|
|
*/
|
|
override measure() {
|
|
this.width = this.minWidth;
|
|
this.height = this.minHeight;
|
|
let connectedBlockWidths = 0;
|
|
for (let i = 0; i < this.elements.length; i++) {
|
|
const elem = this.elements[i];
|
|
this.width += elem.width;
|
|
if (Types.isInput(elem) && elem instanceof InputConnection) {
|
|
if (Types.isStatementInput(elem) && elem instanceof StatementInput) {
|
|
connectedBlockWidths += elem.connectedBlockWidth;
|
|
} else if (
|
|
Types.isExternalInput(elem) &&
|
|
elem instanceof ExternalValueInput &&
|
|
elem.connectedBlockWidth !== 0
|
|
) {
|
|
connectedBlockWidths +=
|
|
elem.connectedBlockWidth - elem.connectionWidth;
|
|
}
|
|
}
|
|
if (!Types.isSpacer(elem)) {
|
|
this.height = Math.max(this.height, elem.height);
|
|
}
|
|
}
|
|
this.connectedBlockWidths = connectedBlockWidths;
|
|
this.widthWithConnectedBlocks = this.width + connectedBlockWidths;
|
|
}
|
|
|
|
override endsWithElemSpacer() {
|
|
return !this.hasExternalInput && !this.hasStatement;
|
|
}
|
|
}
|