@studiocms/ui
Version:
The UI library for StudioCMS. Includes the layouts & components we use to build StudioCMS.
49 lines (48 loc) • 1.45 kB
TypeScript
declare class DropdownHelper {
private container;
private toggleEl;
private dropdown;
private alignment;
private triggerOn;
private fullWidth;
private focusIndex;
active: boolean;
/**
* A helper function to interact with dropdowns.
* @param id The ID of the dropdown.
* @param fullWidth Whether the dropdown should be full width. Not needed normally.
*/
constructor(id: string, fullWidth?: boolean);
/**
* Registers a click callback for the dropdown options. Whenever one of the options
* is clicked, the callback will be called with the value of the option.
* @param func The callback function.
*/
registerClickCallback: (func: (value: string) => void) => void;
/**
* Sets up all listeners for the dropdown.
*/
private initialBehaviorRegistration;
/**
* Registers callbacks to hide the dropdown when an option is clicked.
*/
private initialOptClickRegistration;
/**
* A function to toggle the dropdown.
*/
toggle: () => void;
/**
* A function to hide the dropdown.
*/
hide: () => void;
/**
* A function to show the dropdown.
*/
show: () => void;
/**
* A jQuery-like function to hide the dropdown when clicking outside of it.
* @param element The element to hide when clicking outside of it.
*/
private hideOnClickOutside;
}
export { DropdownHelper };