@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
102 lines (101 loc) • 3.75 kB
TypeScript
import { Dropdown } from './models';
import * as i0 from "@angular/core";
export declare type Events = KeyboardEvent | MouseEvent | FocusEvent;
export declare class DropdownService {
private static minSpaceForDropdown;
private static shouldUseFullHeightDropdownRatio;
private onDocumentClickBinding;
private onDocumentKeydownBinding;
private onWindowScrollBinding;
private onWindowBlurBinding;
private activeDropdown;
/**
* This saves the records for the last opened dropdowns
*/
private dropdownList;
private heightCalculationObject;
/**
* opens a dropdown and sets it to active
* @param dropdown The dropdown to open
* @param calculateHeight Whether to do height calculation
* @param event The event
*/
open(dropdown: Dropdown, calculateHeight?: boolean, displayToSide?: boolean): Promise<void>;
/**
* updates the position of a dropdown so that it remains on screen
* @param dropdown The dropdown to update
* @param calculateHeight Defines whether to calculate height of the dropdown based on window size.
*/
updatePosition(dropdown: Dropdown, calculateHeight?: boolean, displayToSide?: boolean): void;
/**
* Marks a dropdown as closed, if the dropdown is the active dropdown,
* the active dropdown is reset and event handlers are removed.
* @param dropdown The dropdown to close
*/
close(dropdown: Dropdown, event?: Events): void;
/**
* Handles document clicks while a dropdown is open
*/
private onDocumentClick;
/**
* Handles document keydowns while a dropdown is open
*/
private onDocumentKeydown;
/**
* Handles document scrolling while a dropdown is open
*/
private onWindowScroll;
/**
* Handles window blurs while a dropdown is open
*/
private onWindowBlur;
/**
* Handles the position calculation for the left of the dropdown container
* Decides whether to place the dropdown left, right, or on top of the toggle button
*/
private dropdownSetPositionLeft;
/**
* Handles the position calculation for the top of the dropdown container
* Decides whether to place the dropdown above or below the toggle button
*/
private dropdownSetPositionTop;
/**
* It handles the height calculation for the dropdown container
* It calculates based on the heightCalculationObject
* First try to put the dropdown container to decide whether a scroll bar is needed
* Then apply the height from calculation
*/
private dropdownCalculateHeightTop;
/**
* Calculates whether should update the height pixels for the dropdown
*/
private shouldUpdateHeight;
/**
* Get dropdown margin base on the calculation object
*/
private getDropdownMargin;
/**
* Deal with nested close for dropdown
* @param dropdown the active dropdown
* @param event contains the current event target
*/
closeNested(dropdown: Dropdown, event: Events): void;
/**
* It handles closing all the expanded dropdowns
*/
private closeNestedAllExpandedDropdowns;
/**
* It handles closing the dropdown from the component
*/
private closeNestedHelper;
/**
* It handles when opening a dropdown when other dropdown(s) is/are open
*/
private closeNestedOnOpen;
/**
* It handles whether two dropdowns are from the same parent
*/
private isFromSameParent;
static ɵfac: i0.ɵɵFactoryDeclaration<DropdownService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<DropdownService>;
}