UNPKG

pxt-core

Version:

Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors

110 lines (109 loc) 3.19 kB
/// <reference path="../../pxtlib.d.ts" /> import * as Blockly from "blockly"; import { FieldCustom, FieldCustomDropdownOptions } from "./field_utils"; export interface FieldGridPickerToolTipConfig { yOffset?: number; xOffset?: number; } export interface FieldGridPickerOptions extends FieldCustomDropdownOptions { columns?: string; maxRows?: string; width?: string; tooltips?: string; tooltipsXOffset?: string; tooltipsYOffset?: string; hasSearchBar?: boolean; hideRect?: boolean; } export declare class FieldGridPicker extends Blockly.FieldDropdown implements FieldCustom { isFieldCustom_: boolean; private width_; private columns_; private maxRows_; protected backgroundColour_: string; protected borderColour_: string; private tooltipConfig_; private gridTooltip_; private firstItem_; private hasSearchBar_; private hideRect_; private observer; private selectedItemDom; private closeModal_; private selectedBar_; private selectedImg_; private selectedBarText_; private selectedBarValue_; private static DEFAULT_IMG; constructor(text: string, options: FieldGridPickerOptions, validator?: Function); /** * When disposing the grid picker, make sure the tooltips are disposed too. * @public */ dispose(): void; private createTooltip_; /** * Create blocklyGridPickerRows and add them to table container * @param options * @param tableContainer */ private populateTableContainer; /** * Populate a single row and add it to table container * @param row * @param options * @param tableContainer */ private populateRow; /** * Callback for when a button is clicked inside the drop-down. * Should be bound to the FieldIconMenu. * @param {Event} e DOM event for the click/touch * @private */ protected buttonClick_: (e: any) => void; protected buttonClickAndClose_: (e: any) => void; /** * Whether or not to show a box around the dropdown menu. * @return {boolean} True if we should show a box (rect) around the dropdown menu. Otherwise false. * @private */ shouldShowRect_(): boolean; doClassValidation_(newValue: string): string; /** * Closes the gridpicker. */ private close; /** * Getter method */ private getFirstItem; /** * Highlight first item in menu, de-select and de-highlight all others */ private highlightFirstItem; /** * Scroll menu to item that equals current value of gridpicker */ private highlightAndScrollSelected; /** * Create a dropdown menu under the text. * @private */ showEditor_(): void; private positionMenu_; private shouldShowTooltips; private getAnchorDimensions_; private createWidget_; private createSearchBar_; private createSelectedBar_; private updateSelectedBar_; private setupIntersectionObserver_; private disposeIntersectionObserver; /** * Disposes the tooltip DOM. * @private */ private disposeTooltip; private onClose_; }