dropdown.d.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { default as default_2 } from '@thednp/position-observer';
  2. /** Returns a new `BaseComponent` instance. */
  3. declare class BaseComponent {
  4. element: Element;
  5. options?: BaseOptions;
  6. /**
  7. * @param target `Element` or selector string
  8. * @param config component instance options
  9. */
  10. constructor(target: Element | string, config?: BaseOptions);
  11. get version(): string;
  12. get name(): string;
  13. get defaults(): {};
  14. /** just to have something to extend from */
  15. _toggleEventListeners: () => void;
  16. /** Removes component from target element. */
  17. dispose(): void;
  18. }
  19. declare interface BaseOptions {
  20. [key: string]: unknown;
  21. }
  22. /** Returns a new Dropdown instance. */
  23. declare class Dropdown extends BaseComponent {
  24. static selector: string;
  25. static init: (element: Element) => Dropdown;
  26. static getInstance: (element: Element) => Dropdown | null;
  27. element: HTMLElement;
  28. options: DropdownOptions;
  29. open: boolean;
  30. parentElement: HTMLElement;
  31. menu: HTMLElement;
  32. _observer: default_2;
  33. /**
  34. * @param target Element or string selector
  35. * @param config the instance options
  36. */
  37. constructor(target: Element | string, config?: Partial<DropdownOptions>);
  38. /**
  39. * Returns component name string.
  40. */
  41. get name(): string;
  42. /**
  43. * Returns component default options.
  44. */
  45. get defaults(): {
  46. offset: number;
  47. display: string;
  48. };
  49. /** Shows/hides the dropdown menu to the user. */
  50. toggle(): void;
  51. /** Shows the dropdown menu to the user. */
  52. show(): void;
  53. /** Hides the dropdown menu from the user. */
  54. hide(): void;
  55. /**
  56. * Toggles on/off the `click` event listener of the `Dropdown`.
  57. *
  58. * @param add when `true`, it will add the event listener
  59. */
  60. _toggleEventListeners: (add?: boolean) => void;
  61. /** Removes the `Dropdown` component from the target element. */
  62. dispose(): void;
  63. }
  64. export default Dropdown;
  65. declare interface DropdownOptions extends BaseOptions {
  66. offset: number;
  67. display: string | "dynamic" | "static";
  68. }
  69. export { }