UNPKG

wj-elements

Version:

WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.

85 lines (84 loc) 2.73 kB
import { default as WJElement } from '../wje-element/element.js'; import { default as Popup } from '../wje-popup/popup.element.js'; /** * `Dropdown` is a custom element that displays a dropdown menu. * @summary This element represents a dropdown menu. * @documentation https://elements.webjet.sk/components/dropdown * @status stable * @augments {WJElement} * @csspart native - The native part of the dropdown. * @slot trigger - The slot for the trigger of the dropdown. * @slot - The default slot for the dropdown. * // @fires wje-dropdown:open - Event fired when the dropdown is opened. * // @fires wje-dropdown:close - Event fired when the dropdown is closed. * @tag wje-dropdown */ export default class Dropdown extends WJElement { /** * Getter for the CSS stylesheet. * @returns {string[]} */ static get observedAttributes(): string[]; /** * The placement of the dropdown. * @type {{"wje-popup": Popup}} */ dependencies: { "wje-popup": Popup; }; /** * Sets the placement of the dropdown. * @param value */ set trigger(value: string | string); /** * Gets the placement of the dropdown. * @returns {string|string} */ get trigger(): string | string; /** * Callback function to handle other dropdowns being opened. Close the dropdown if it is not the target and collapse is enabled. * @param {Event} e The event object. */ otherDropdownOpennedCallback: (e: Event) => void; /** * Removes the popup element. */ beforeDraw(): void; popup: HTMLElement; /** * Draws the dropdown element and returns the created document fragment. * @returns {DocumentFragment} */ draw(): DocumentFragment; anchorSlot: HTMLSlotElement; popupHideCallback: () => void; /** * Adds event listeners for the mouseenter and mouseleave events. */ afterDraw(): void; /** * @summary Returns the content to be displayed before showing the dropdown. * @returns {any} The content to be displayed. */ beforeShow(): any; /** * This method is called after the dropdown is shown. */ afterShow(): void; /** * @summary Toggles the dropdown element between active and inactive states. * Calls the `onOpen` method if the element is currently inactive, * and calls the `onClose` method if the element is currently active. * @param {Event} e The event object. */ toggleCallback: (e: Event) => void; /** * Open the popup element. * @param {object} e */ onOpen: (e: object) => void; beforeClose: () => void; afterClose: () => void; onClose: (e: any) => void; }