pxt-core
Version:
Microsoft MakeCode provides Blocks / JavaScript / Python tools and editors
101 lines (100 loc) • 3.08 kB
TypeScript
/// <reference path="../../pxtlib.d.ts" />
import { FieldCustom, FieldCustomDropdownOptions } from "./field_utils";
import { FieldDropdownGrid } from "./field_dropdowngrid";
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 FieldDropdownGrid implements FieldCustom {
private tooltipConfig_;
private gridTooltip_;
private firstItem_;
private hasSearchBar_;
private observer;
private selectedItemDom;
private closeModal_;
private selectedBar_;
private selectedImg_;
private selectedBarText_;
private selectedBarValue_;
protected scrollContainer: HTMLDivElement;
private static DEFAULT_IMG;
private firstFocusableElement;
private lastFocusableElement;
private tabKeyBind;
constructor(text: string, options: FieldGridPickerOptions, validator?: Function);
protected setFocusedItem_(_gridItemContainer: HTMLElement): void;
/**
* 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 {string | null} value the value to set for the field
* @private
*/
protected buttonClick_: (value: string | null) => void;
protected buttonClickAndClose_: (value: string | null) => void;
doClassValidation_(newValue: string): string;
getFieldDescription(): string;
/**
* Closes the gridpicker.
*/
private close;
/**
* 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_(e?: Event): 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_;
private handleTabKey;
private addKeyboardNavigableClass;
}